Need Some VB Help

Discussion in 'OT Technology' started by m0rningbreakfast, Feb 26, 2003.

  1. m0rningbreakfast

    m0rningbreakfast New Member

    Joined:
    Dec 20, 2002
    Messages:
    4,835
    Likes Received:
    0
    Location:
    Sunnyvale - San Jose, CA
    Gotta make a program which displays your marital status when you type in a certain letter. For any inncorrect ones, I have to display a msgbox, but I can't seem to get it to work and the teacher's Engrish lecture isn't helping me much.
    -------------------------------------------
    Newb :code:

    Private Sub cmd_Click()

    Dim status As String
    Title = "Input Box"
    Title2 = "Message Box of Doom"
    status = InputBox("Please type in the appropriate letter now", Title)


    If status = "w" Then
    picbox.Print "You are widowed then."
    Else
    If status = "m" Then
    picbox.Print "You are married, good for you."
    Else
    If status = "s" Then
    picbox.Print "You are single, join the club buddy."
    Else
    If status = "d" Then
    picbox.Print "You are either divored or in the process of being divorced."
    If status <> m Then
    status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    Else
    If status <> d Then
    status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    Else
    If status <> s Then
    status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    Else
    If status <> w Then
    status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End Sub
    ---------------------------------------
    Private Sub cmd2_Click()
    picbox.Cls


    End Sub

    ---------------------------------------

    THE W,S,D,M work ok, but when I type in y nothing pops up. Help.
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Holy confusing. Well, not to change things around too much because that's a crap way of doing things, but try using this method:

    Code:
    If status = "w" Then
         picbox.Print "You are widowed then."
    else if status = "m" Then
         picbox.Print "You are married, good for you."
    else if status....
         picbox.print...
    ...
    else
         status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    end if
    
    BTW, else if might be elseif - can't remember.
     
  3. Slimmy

    Slimmy Get Richt or Die Trying

    Joined:
    Mar 14, 2000
    Messages:
    135,671
    Likes Received:
    29
    Location:
    Ft. Lauderdale
    Like he said, just use one if statement, and a buncha ElseIf's, and it is ElseIf, not Else If. :)
     
  4. Slimmy

    Slimmy Get Richt or Die Trying

    Joined:
    Mar 14, 2000
    Messages:
    135,671
    Likes Received:
    29
    Location:
    Ft. Lauderdale
    Looking at that again, my teacher would rip you a new one if you handed that in. :o
     
  5. Slimmy

    Slimmy Get Richt or Die Trying

    Joined:
    Mar 14, 2000
    Messages:
    135,671
    Likes Received:
    29
    Location:
    Ft. Lauderdale
    You could also shorten the last part into one line, because since you've already said the 4 letters that it can equal and set the return for those, if you simply end with

    Code:
    Else
    
    status = MsgBox("Wrong letter entered! Check the LEGENDS!", Title2)
    
    End If
    It would display that message for any letter entered other than those 4. :)
     
  6. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Didn't I say that? ;)
     
  7. Slimmy

    Slimmy Get Richt or Die Trying

    Joined:
    Mar 14, 2000
    Messages:
    135,671
    Likes Received:
    29
    Location:
    Ft. Lauderdale
    Yes, I noticed that after my post, but I thought the elipses might confuse him. :)
     

Share This Page