Results 1 to 5 of 5

Thread: Displaying Entered Name on other forms

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    13

    Unhappy

    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





  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    Code:
    Private Sub Form_Load()
       Label1.Caption = Form1.Text1.Text
    End Sub

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    You might want to assign the name to a global (public) variable if you're going to be using it in every form.
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Since your totally new global variables go into Modules so open one up, and type it
    Code:
    Global Name 'name can be changed to anything
    so now that can be used on any form.

  5. #5
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    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:
    Code:
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width