can somebody please tell me what code i have to write to make a new window appear.
Printable View
can somebody please tell me what code i have to write to make a new window appear.
to make a new form appear:
VB Code:
form2.show
ok but i want to make form 1 edited by form 2
ex: i want to be able to type a vlue in to a text field(in for 2) and press ok and the the label in text one will show the value...for example form 2 will ask what is your name and i will type Anuj and click ok and then a label will apear in form 1 saying hello anuj,
so type a value into Text1 and then have it displayed onto form2 as a caption?
Form1
VB Code:
Option Explicit Public pName As String Private Sub Command1_Click() pName = Text1.Text Me.Hide Form2.Show End Sub
Form2
VB Code:
Private Sub Form_Load() Label1.Caption = "Hello '" & Form1.pName & "'" End Sub
that what u wanted?
thanks alot man
Hmmm if you want to do it properly then do:
In form 2 do:
Then in form 1 do:VB Code:
Option Explicit Private mstrUsername As String Public Property Let Username(ByVal Value As String) mstrUsername = Value End Property Private Sub Form_Load() lblUsername.Caption = "Hello " & mstrUsername End Sub
Much much neater coding. There is never any need for public varibles in a form.VB Code:
Option Explicit Private Sub Command1_Click() Dim frmNew As Form2 Set frmNew = New Form2 frmNew.Username = Text1.Text Load frmNew frmNew.Show Set frmNew = Nothing End Sub
Woka