displaying first form textbox field value as label value in next form

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
hello every one
good afternoon
actually i am developing a small project on bank
my first form consists of bank name which is dispalyed in a textbox.
now i want to display the entered textbox value say(any bank name "AA")
in next form as a label
the method i used id
1.
create one object of form1
and call it in the next form as follows

i wrote this code in second form

dim f as new form1
label1.text=f.textbox1.text( here label is in the second form)
reply soon
 
Hi,

Form1:

VB.NET:
Public[/color][/size][size=2] [/size][size=2][color=#0000ff]Shared[/color][/size][size=2] txtF1 [/size][size=2][color=#0000ff]As[/color][/size][size=2] TextBox

[/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] Button1_Click([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, _[/size]
[size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] Button1.Click
txtF1 = TextBox1

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] nform [/size][size=2][color=#0000ff]As[/color][/size][size=2] Form = [/size][size=2][color=#0000ff]New[/color][/size][size=2] Form2

nform.Show()

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub

form2:

VB.NET:
Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] Form2_Load([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] [/size][size=2][color=#0000ff]MyBase[/color][/size][size=2].Load

[/size][size=2][color=#0000ff]Me[/color][/size][size=2].Label1.Text = Form1.txtF1.Text

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub


Please let me know if you need additional help ... cheers:)
 
For this problem, what if it is in the web application and not in form? How to display the entered value from the textbox1 in webform1.aspx and display in webform2.aspx label?
 
For the web forms it is easy to pass textbox value through query string
to assign it to label in the another form

Regards,
Prasad
 
displaying first form textbox field value as label value in next form

in the form2 add overloaded method

Public Sub New(ByVal strBankName As String)
MyBase.New()
label1.text = strbankname


'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

in the Form1 on button click
add this code
Dim objfrm As Form2 = New Form2(textbox1.text)
objfrm.DialogResult = objfrm.ShowDialog()

I hope this is best method.

Regards,
Prasad
 
Back
Top