|
-
Apr 8th, 2001, 08:28 PM
#1
Ok, so I'm new to VB.
I have VB 5.0 Professional Edition.
What I want is quite simple, just to chnage the caption of a form in run time.
So, on form 1, there is a text box and a command button, when the button is pressed, it assigns the text in the text box to a variable, then hides the current form and shows another form.
On the new form, when it loads, I have it so the caption is changed to the variable...
However, in run time, it stays blank.
I'm presuming it's cos the variable isn't global?
It's defined in a 'private' sub, so I when I call it in other places it isnt recognized?
Im not sure, new to VB as I say 
To change screen do I have to go to a new form?
Or could I put two layouts on there, and when I push the button, it makes certain controls visable property to false and opther to true?
But that seems teidious if Im gunna need several screens?
Any ideas?
-
Apr 8th, 2001, 08:37 PM
#2
PowerPoster
Add a Command Button control and paste this code into your Form will do.
Code:
Option Explicit
Private Sub Command1_Click()
Dim F As Form1
Set F = New Form1
Load F
F.Caption = Text1.Text
F.Show
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim F As Form
For Each F In Forms
Unload F
Set F = Nothing
Next
End
End Sub
'Code improved by vBulletin Tool (Save as...)
-
Apr 8th, 2001, 08:37 PM
#3
???
Code:
'Form1
Private Sub Command1_Click()
Load Form2
Form2.Caption = Text1.Text
Form2.Show
End Sub
does that work?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 8th, 2001, 08:48 PM
#4
Both ways work!!
Thanks alot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|