Click to See Complete Forum and Search --> : VB newbie question


m316foley
04-17-2001, 08:21 PM
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*

richardginn
04-18-2001, 11:01 AM
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 (http://www.geocities.com/richardginn/templatehtml) -Come visit the Template HTML homepage

m316foley
04-18-2001, 05:50 PM
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*

m316foley
04-18-2001, 06:56 PM
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*

Milkman
04-18-2001, 07:02 PM
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"

Fiddler
04-19-2001, 03:48 PM
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

Milkman
04-19-2001, 04:26 PM
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"

m316foley
04-19-2001, 08:58 PM
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*

Milkman
04-20-2001, 03:26 PM
it is posted above http://www.sharkyforums.com/ubb/smile.gif

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"

siyan_c
04-22-2001, 07:13 PM
Originally posted by Milkman:
it is posted above http://www.sharkyforums.com/ubb/smile.gif

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



No variables needed. http://www.sharkyforums.com/ubb/smile.gif

-----

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!

m316foley
04-22-2001, 09:08 PM
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*

Milkman
04-23-2001, 08:59 PM
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"

m316foley
04-23-2001, 09:47 PM
that still doesnt answer my question above!

------------------
*HAVE A NICE DAY*

Milkman
04-24-2001, 07:33 PM
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"

m316foley
04-24-2001, 07:38 PM
it doesnt though

------------------
*HAVE A NICE DAY*