VB newbie question

Sharky Forums


Results 1 to 15 of 15

Thread: VB newbie question

  1. #1
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post VB newbie question

    I am doing a project. This is what I want to do....

    It asks a question through a msgbox....
    then an input box will pop up so they can answer it,
    then this is what I need to know.....how to make it say something like "Im sorry you have gotten this wrong, or im sorry you have gotten this right" and then a box pops up and says would you like to retry, or just get the answer. thanks a lot if you can help!

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  2. #2
    Ultra Great White Shark!! richardginn's Avatar
    Join Date
    Feb 2001
    Posts
    16,118

    Post

    first set some variable to 0.

    then use a WHILE loop.

    load up the message box

    load up the input box

    Get the input from the messagebox

    check the Input from the message box

    Using simple IF statments here:

    If the user is correct the variable changes to some other number than 0 and a NEW message box comes up telling the user he is correct.

    if the user is wrong the variable does not change and a NEW message box comes up saying that he is wrong and it will have two buttons on it.

    One to restart the question and one to just move on.


    If he clicks on the restart the question we go through the loop again.

    If he click on the just move on button the variable changes it number to something other than 0 and the loop is teminated.


    ------------------
    www.geocities.com/richardginn/templatehtml -Come visit the Template HTML homepage
    www.myeducational plan.com-come see my plan to fix the USA educational system. I hope this is sig legal. Major Site Design Update on July 18, 2006. On June 18, 2009 passed the 10,000 post mark. December 24, 2009: Major Theme change and more....

  3. #3
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    I know how to do most of it, but I need something like an example to mess around with, could you please give me one?

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  4. #4
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    Originally posted by richardginn:
    first set some variable to 0.

    then use a WHILE loop.

    load up the message box

    load up the input box

    Get the input from the messagebox

    check the Input from the message box

    Using simple IF statments here:

    If the user is correct the variable changes to some other number than 0 and a NEW message box comes up telling the user he is correct.

    if the user is wrong the variable does not change and a NEW message box comes up saying that he is wrong and it will have two buttons on it.

    One to restart the question and one to just move on.


    If he clicks on the restart the question we go through the loop again.

    If he click on the just move on button the variable changes it number to something other than 0 and the loop is teminated.


    I know how to do most of it, but I need something like an example to mess around with, could you please give me one?

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  5. #5
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Next door.
    Posts
    546

    Post

    I actually trie that also. this is what I came up with:

    Private Sub Command1_Click()
    proceed = MsgBox("Your text here", vbOKCancel, Text)
    'above code makes message box equal to the variable
    'proceed, now write an if statement, if the person proceeds
    If proceed Then
    input1 = InputBox("What is the password?", "???")
    End If
    'now check to see if what the user inputed is correct
    If input1 = "yourpassword" Then
    MsgBox "You are correct"
    Else
    MsgBox "You suck, try again!"
    End If
    End Sub

    that is the basic structure...I do not know about loops and stuff in VB yet.

    ------------------
    "There are two steps to success: 1. Never tell everything you know 2. See #1"
    BLAH

  6. #6
    Expensive Sushi
    Join Date
    Sep 2000
    Location
    Edison, NJ
    Posts
    34

    Post

    I dont see why you use a messagebox AND an input box. why not just use an input box to ask the question? you can use vbCrLf to separate lines.
    answer=inputbox("this is my question" & vbCrLf & "what is your answer?")


    ------------------
    -Fiddler
    -Fiddler

  7. #7
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Next door.
    Posts
    546

    Post

    I was just writing the code that m316foley wanted. he wants a message box to ask whether the visitor wants to proceed, and then ask the questiom.

    ------------------
    "There are two steps to success: 1. Never tell everything you know 2. See #1"
    BLAH

  8. #8
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    Originally posted by Milkman:
    I was just writing the code that m316foley wanted. he wants a message box to ask whether the visitor wants to proceed, and then ask the questiom.


    So do you know the code?

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  9. #9
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Next door.
    Posts
    546

    Post

    it is posted above

    accept...i do not know how to write the loop to loop it...

    ------------------
    "There are two steps to success: 1. Never tell everything you know 2. See #1"
    BLAH

  10. #10
    Reef Shark siyan_c's Avatar
    Join Date
    Nov 2000
    Posts
    357

    Post

    Originally posted by Milkman:
    it is posted above

    accept...i do not know how to write the loop to loop it...

    No variables needed.

    -----

    Public Sub Whatever()

    If MsgBox("Hello?", vbYesNo) = vbYes Then

    Do While Inputbox("Question?") <> "Answer"
    MsgBox "WRONG!"
    Loop

    MsgBox "GENIUS!"

    End If

    End Sub

    ----

    Something like that...if it doesn't work, Meh.


    ------------------
    This signature is SPAM!
    meh.

  11. #11
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    Can some1 help me with this code? When i keep trying to run it it says "End if without block if". Then it highlights the first "End if", so whats wrong? By the way, I am using Visual Basic 3. If anyone knows where I can get a higher version please tell me.


    Sub Command1_Click ()
    proceed = MsgBox("Please translate the word Uno into English.", 1, Text) = 1
    Unload Me
    End
    End If
    If proceed Then
    input1 = InputBox("Please enter your answer below!", "???")
    If input1 = "one" Then
    MsgBox "You are correct"
    Else
    proceed2 = MsgBox("I'm sorry, that is incorrect. Please try again!", 1, Text) = 1
    Unload Me
    End
    End If
    End Sub


    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  12. #12
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Next door.
    Posts
    546

    Post

    Sub Command1_Click ()
    proceed = MsgBox("Please translate the word Uno into English.", 1, Text) = 1
    Unload Me
    -End
    End If
    If proceed Then
    input1 = InputBox("Please enter your answer below!", "???")
    If input1 = "one" Then
    MsgBox "You are correct"
    Else
    proceed2 = MsgBox("I'm sorry, that is incorrect. Please try again!", 1, Text) = 1
    Unload Me
    -End
    End If
    End Sub

    you do not need the ends after unload me. and use the other guys code. IT IS BETTER! lol

    ------------------
    "There are two steps to success: 1. Never tell everything you know 2. See #1"
    BLAH

  13. #13
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    that still doesnt answer my question above!

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

  14. #14
    Tiger Shark
    Join Date
    Mar 2001
    Location
    Next door.
    Posts
    546

    Post

    the above method will eliminate your block if/end if problem

    ------------------
    "There are two steps to success: 1. Never tell everything you know 2. See #1"
    BLAH

  15. #15
    Hammerhead Shark m316foley's Avatar
    Join Date
    Nov 2000
    Posts
    2,706

    Post

    it doesnt though

    ------------------
    *HAVE A NICE DAY*
    Amd Athlon Mobile 2600+ (200 X 12.5 @ 1.7)
    Asus A7N8X-Deluxe (Not Rev. 2)
    2-80gig WD Hard drives
    Corsair XMS pc3200 - 512megs
    Saphire Radeon 9800pro
    Soundblaster Live Platinum 5.1
    3Com EtherLink 10/100 3CR990-TX-97
    Creative Blaster v.92 Modem
    Sony Trinitron 21inch Monitor
    Plextor 24X Burnproof Cd-Writer
    Pioneer 16X DVD Drive
    Klipsch Ultras 5.1 Surround Sound
    Sony 3.5inch Floppy Drive
    Windows 2k of course...
    -------------------------
    Bart: Hey! Why is it killing my toys?
    Lisa: They must have programed it to destroy the competition.
    Bart: Sort of like Microsoft!
    -------------------------
    *HAVE A NICE DAY*

Posting Permissions

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