有没有办法在 vb.net 中的表单之间传递值?(不使用公共变量)

有没有办法在 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.