please help me , form2 click button

bahram

Member
Joined
May 1, 2006
Messages
13
Programming Experience
1-3
please help me :

i have 2 form

form1 : a button + textbox1

form2 : a textbox2 + button2 + label2

now when run application open form1 by a button i need when i type value in textbox1 and click this button form2 open and textbox2 .text= textbox1.text and run buttn2 clich event automaticly and for example label1.text chang ?

i dont click button2 this event run automaticly ?
plaese help me
 
What you should do then it write a new property or method to class form2, it could be for example property myText or method SetText, this way of doing things depend on how you want to interact the Text to/from this form class. You can limit the property to readonly or writeonly, the distictino between a method and a property is that properties are used to handle single values (and can do additional stuff in response to value change) and methods implies 'doing some action'. Examples including method:
VB.NET:
Public ReadOnly Property myGetText() As String
Get
  Return TextBox1.Text
End Get
End Property
 
Public Property myGetSetText() As String
Get
  Return TextBox1.Text
End Get
Set(ByVal value As String)
  TextBox1.Text = value
End Set
End Property
 
Public WriteOnly Property mySetText() As String
Set(ByVal value As String)
  TextBox1.Text = value
End Set
End Property
 
Public Sub SetText(ByVal value As String)
  TextBox1.Text = value
End Sub
Which option you choose yourself, I would say writeonly property suits the request best. Use it like any other class property or method:
VB.NET:
Dim f As New Form2
f.mySetText = Me.TextBox1.Text 'Me is here your form1 instance
f.ShowDialog()
 
Back
Top