Results 1 to 12 of 12

Thread: help with msgbox and text1

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    42

    help with msgbox and text1

    have made it before, but cant remeber the code. I want it so that when
    anything is written in text1 it = "Hello (Name)"
    get what i mean?
    if not, i want it so that when anything is written in text one, and i hit the command button it says "hello (entered name)"

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: help with msgbox and text1

    In the command button's Click try,

    MsgBox "Hello " & Text1.Text

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    42

    Re: help with msgbox and text1

    that worked, but i want to make so that if it isnt blank the message gets displayed, basically:
    If Text1 = "" Then
    MsgBox "You must enter your name"
    End If
    MsgBox "Hello " & Text1.Text

    is what i have so far (thanks to you =p) but i need it to make it so that it cant be blank i thought it was
    elseif text1 = <> "" & text1.text

    but im not sure..

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: help with msgbox and text1

    Quote Originally Posted by Badboyjt432
    that worked, but i want to make so that if it isnt blank the message gets displayed, basically:
    If Text1 = "" Then
    MsgBox "You must enter your name"
    End If
    MsgBox "Hello " & Text1.Text

    is what i have so far (thanks to you =p) but i need it to make it so that it cant be blank i thought it was
    elseif text1 = <> "" & text1.text

    but im not sure..
    Well if you don't want to continue if no name was entered the why not just exit the button_click sub?

    If Text1.Text = "" Then
    MsgBox "You must enter your name"
    Exit Sub
    End If

    MsgBox "Hello " & Text1.Text

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    42

    Re: help with msgbox and text1

    THANK YOU! thats what i wanted!

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2008
    Posts
    42

    Re: help with msgbox and text1

    i need more help..well for starters all my .frm's when i try to open them, nothing shows up, no error, no code, no anything.. Next, my audio player that i made is saying that:
    If Combo1 = "The Misfits - Saturday Night" Then
    MsgBox "Copyrighted By: Taylor (aka PhReAkInGjt or Jtst1"
    End If
    If Combo1 = "The Misfits - Saturday Night" Then
    Call Playwave("The Misfits - Saturday Night.WAV", 1)
    End If

    Call cannot be defined? I have a working version of this, but i dont know what to do.

  7. #7
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: help with msgbox and text1

    I don't understand this. Is "call cannot be defined" error that you get? On what line?

    Why are you trying to hard code this anyways?

  8. #8
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: help with msgbox and text1

    Also the code
    Code:
    If Combo1 = "The Misfits - Saturday Night" Then
    is very ambiguous, do you mean to say
    Code:
    If Combo1.Text = "The Misfits - Saturday Night" Then

  9. #9
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: help with msgbox and text1

    @Ione REBEL: you're true but his version is still correct. You don't need to specify Control's Property if it's default. For example:
    Code:
    Picture1 = LoadPicture("c:\windows\gone fishing.bmp") 'instead of Picture1.Picture = ...
    ... will work, since .Picture is PictureBox's default Property.

    I'm also against this syntax but it's correct

  10. #10
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: help with msgbox and text1

    LOL, thats true.
    I also said it was AMBIGUOUS, not that it won't work. I used to do that too, when I was a newbie ROFL. I was just pointing out that it was not a very good programming practice. I also consider the code given by EdgeMeal:
    Code:
    If Text1.Text = "" Then
       MsgBox "You must enter your name"
       Exit Sub
    End If
    MsgBox "Hello " & Text1.Text
    to be not a very good programming practice since it is making things complex. I would rather use:
    Code:
    If Text1.Text = "" Then
       MsgBox "You must enter your name"
    Else
       MsgBox "Hello " & Text1.Text
    End If
    Does that not work exactly like the former code? And its much simpler and easier to understand.

  11. #11

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: help with msgbox and text1

    Quote Originally Posted by Badboyjt432
    i need more help..well for starters all my .frm's when i try to open them, nothing shows up, no error, no code, no anything.. Next, my audio player that i made is saying that:
    If Combo1 = "The Misfits - Saturday Night" Then
    MsgBox "Copyrighted By: Taylor (aka PhReAkInGjt or Jtst1"
    End If
    If Combo1 = "The Misfits - Saturday Night" Then
    Call Playwave("The Misfits - Saturday Night.WAV", 1)
    End If

    Call cannot be defined? I have a working version of this, but i dont know what to do.
    What does the Playwave procedure look like?

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