Results 1 to 10 of 10

Thread: text box to label

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    44

    text box to label

    -New User

    I have a text box where a user types in his/her name. When the user clicks the command1 button the label2.caption will read

    "welcome ___ to the...."

    what code do I write in the command1 so whatever name i put in the text will be between "welcome" and "to the..."

    label2.caption="?"

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: text box to label

    Piece strings together via contcatenation; using &

    Example: MsgBox "Hello " & "World. " & "How are you?"
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: text box to label

    Code:
    Private Sub Command1_Click()
    
        Label1.Caption = "welcome " & Text.Text & " to VBForums."
    
    End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    44

    Re: text box to label

    Quote Originally Posted by LaVolpe View Post
    Piece strings together via contcatenation; using &

    Example: MsgBox "Hello " & "World. " & "How are you?"
    sorry I don't understand your example , this is what I want
    where it says "text1.text" should be whatever the user typed in the text1.text box.

    label2.caption = "welcome text1.text to the..."

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: text box to label

    label2.caption = "welcome " & text1.text & " to the..."

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    44

    Re: text box to label

    Quote Originally Posted by TysonLPrice View Post
    Code:
    Private Sub Command1_Click()
    
        Label1.Caption = "welcome " & Text.Text & " to VBForums."
    
    End Sub
    Thank You

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    44

    Re: text box to label

    I also want the name from text1.text from form1 to appear on label1.caption on form2.

    label1.caption="Please (text1.text from form1) select an option"

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: text box to label

    Any control on any form can be accessed from any form. Just precede the control with the form's name:

    Form1.Text1.Text
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: text box to label

    label1.caption="Please " & form1.text1.text & " select an option"

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    44

    Re: text box to label

    Quote Originally Posted by LaVolpe View Post
    Any control on any form can be accessed from any form. Just precede the control with the form's name:

    Form1.Text1.Text
    Thank You

    Quote Originally Posted by TysonLPrice View Post
    label1.caption="Please " & form1.text1.text & " select an option"

    Thank You

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