PDA

Click to See Complete Forum and Search --> : Displaying Entered Name on other forms


Obie
Aug 24th, 2000, 10:43 PM
Hi,
I am completely new to VB. My lecturer however has thrown a game assignment at me where I have to make a Digimon game.

One of the requirements is getting the user to enter their name. I have done this via a txtbox. If user does not enter their name and press the cmdStart button, a msgbox opens asking them to do so.

If they have entered atleast 1 character and press the button then the first form dissapears appears and you move onto a second form where the actual game is played.

However I need to display the entered name on subsequent forms automatically as they open up. I thought of displaying the name in a label. I think the first event of the second form will be:

Private Sub Form_Load()........however where do i go from there?

Thanks
Obie

Cybrg641
Aug 24th, 2000, 11:16 PM
Private Sub Form_Load()
Label1.Caption = Form1.Text1.Text
End Sub

HarryW
Aug 26th, 2000, 08:15 AM
You might want to assign the name to a global (public) variable if you're going to be using it in every form.

SteveCRM
Aug 26th, 2000, 12:27 PM
Since your totally new ;) global variables go into Modules so open one up, and type it

Global Name 'name can be changed to anything

so now that can be used on any form.

Warmaster199
Aug 26th, 2000, 01:59 PM
What else you could do is load up every form in the Form_Load() event in your first form. That way, it would be very easy to set the captions of the forms. Then, when you press ok or whatever, make it so that the text in the textbox = the caption of the form(s). You can do this like this:

Private sub Form_Load()
'load first form into memory
load form2
End sub

Private sub cmdOK_Click()
'set the textbox text as form captions.
txtbox1.text = form2.caption
end sub

Good luck on your game!