有没有办法在 vb.net 中的表单之间传递值?(不使用公共变量) [英] Is there a way to pass values between forms in vb.net? (Without using a public variable)

查看:25
本文介绍了有没有办法在 vb.net 中的表单之间传递值?(不使用公共变量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用带有 textBox 和按钮的第二个表单,我需要将文本从 textBox 传递到第一个表单.我知道如何使用公共变量来实现,但我想知道是否有另一种方法可以在不使用公共变量的情况下做到这一点.

I have an application that uses a second form with textBox and button, and i need to pass the text from textBox to the first form. I know how to do it with a public variable, but i would like to know if there is another way to do it without using a public variable.

推荐答案

您可以使用第二个表单上的 PUBLIC 属性来读取/写入另一个表单的信息.

You can use PUBLIC properties on the second form to read/write info to the other form.

您可以重载 NEW 方法以在声明期间传递变量.

You can overload the NEW method to pass variable during declaration.

您可以在第二种形式上创建一个公共子/函数并传递变量 byval 或 byref.

You can create a public sub/function on the second form and pass variable byval or byref.

但是,我永远不会使用公共变量.那是糟糕的编程.

But, I would NEVER use a public variable. That is bad programming.

这篇关于有没有办法在 vb.net 中的表单之间传递值?(不使用公共变量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆