vb.net 以另一种形式将文本框值发送到标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22528111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:09:40  来源:igfitidea点击:

send textbox value to label in another form

vb.net

提问by drjester

i have 4 form : input, form1, form2, form3

我有 4 个表单:输入、表单 1、表单 2、表单 3

input have 3 input : a, b, c
form1 label1 need form1.a
form2 label1 need form1.b
form3 label1 need form1.c

输入有3个输入:a,b,c
form1 label1需要form1.a
form2 label1需要form1.b
form3 label1需要form1.c

after i click a button in input, form1 show and in several second change to form 2 and that's happen to form2 too, it change to form3, and form3 change into form1. it looping the changing beetwen form

在我单击输入中的按钮后,form1 显示并在几秒钟内更改为 form2,这也发生在 form2 中,它更改为 form3,而 form3 更改为 form1。它循环变化的 beetwen 形式

i try this code to send the value

我尝试使用此代码发送值

Form1.label1.Text = a.Text
Form2.label1.Text = b.Text
Form3.label1.Text = c.Text

and i try this code to create the looping beetwen form
in form1

我尝试使用此代码
在 form1 中 创建循环甜菜窗体

form2.show()
me.close  

in form2

在form2中

form3.show()
me.close  

in form3

在form3中

form1.show()
me.close  

the problem is the value sometimes missing and the form not loop like i want anymore
please help

问题是有时会丢失值并且表单不再像我想要的那样循环,
请帮助

回答by Hoh

Define Private MyInput As String = ""right bellow your class name.

Private MyInput As String = ""在您的班级名称下方定义。

Add this subto all forms

将此添加sub到所有表单

    Public Sub ContinueInit(ByVal input as string)
    Me.MyInput = input
    Me.Label1.Text = input
    End Sub

Then, in Button Clicksadd this depends on what form you want to call:

然后,Button Clicks添加这取决于您要调用的形式:

form1.show()
form1.ContinueInit(a.text)
me.close

form2.show()
form2.ContinueInit(b.text)
me.close

form3.show()
form3.ContinueInit(c.text)
me.close  

I hope this helped you to solve your problem. There is an easier way to do it, but this is what I am doing since I got used to this method.

我希望这能帮助你解决你的问题。有一种更简单的方法可以做到,但这就是我习惯了这种方法后所做的。