Some hints that might get you started. But maybe there are better ways, I'm not good with VBScript
Create some text on the screen by right clicking on it. Enter something (doesn't matter what, I entered
question)
Create a hotspot where you have entered the text before, but over the whole width of the screen (since the question will be longer than the word
question)
Go to the Frame Properties and add
- Code: Select all
Text(1).caption= "Hello Human. Would you like to drink"+vblf+ "coffee or drink water?"
Go to VBS Procedures, and create subroutines for the answers.
Working example:
- Code: Select all
Sub Question1
answer1 = "drink coffee"
answer2 = "drink water"
Do
returnvalue = InputBox("Please enter your answer.","Answer")
Select Case returnvalue
Case ""
MsgBox "Okay, think again."
Exit Do
Case answer1
Text(1).caption= "I see, you're a coffee addict." +vblf+ "Sugar or no sugar? "
question1_ok=1
Exit Do
Case answer2
Text(1).caption= "Well, water is healthy."+vblf+ "Do you agree? "
question1_ok=2
Exit Do
Case Else
Text(1).caption= "Sorry, I don't understand what you are saying." +vblf+ "Drink coffee or drink water? "
End Select
Loop
End Sub
Sub Question2
answer1 = "sugar"
answer2 = "no sugar"
Do
returnvalue = InputBox("Please enter your answer.","Answer")
Select Case returnvalue
Case ""
MsgBox "Okay, think again."
Exit Do
Case answer1
Text(1).caption= "I like coffee with sugar, too." +vblf+ "Do you prefer dog or cat?"
question2_ok=1
Exit Do
Case answer2
Text(1).caption= "Ugh, I hate coffee without sugar." +vblf+ "Do you prefer cookie or cake?"
question2_ok=2
Exit Do
Case Else
Text(1).caption= "Sorry, I don't understand what you are saying. Try again "
End Select
Loop
End Sub
Sub Question3
answer1 = "yes"
answer2 = "no"
Do
returnvalue = InputBox("Please enter your answer.","Answer")
Select Case returnvalue
Case ""
MsgBox "Okay, think again."
Exit Do
Case answer1
Text(1).caption= "Great!"
question3_ok=1
Exit Do
Case answer2
Text(1).caption= "I think you're wrong."
question3_ok=2
Exit Do
Case Else
Text(1).caption= "Sorry, I don't understand what you are saying. Try again "
End Select
Loop
End Sub
Sub Question4
answer1 = "dog"
answer2 = "cat"
Do
returnvalue = InputBox("Please enter your answer.","Answer")
Select Case returnvalue
Case ""
MsgBox "Okay, think again."
Exit Do
Case answer1
Text(1).caption= "Dogs are wonderful!"
question4_ok=1
Exit Do
Case answer2
Text(1).caption= "Cats are very nice!"
question4_ok=2
Exit Do
Case Else
Text(1).caption= "Sorry, I don't understand what you are saying. Try again "
End Select
Loop
End Sub
Sub Question5
answer1 = "cookie"
answer2 = "cake"
Do
returnvalue = InputBox("Please enter your answer.","Answer")
Select Case returnvalue
Case ""
MsgBox "Okay, think again."
Exit Do
Case answer1
Text(1).caption= "Yummy cookies!"
question4_ok=1
Exit Do
Case answer2
Text(1).caption= "Me, too!"
question4_ok=2
Exit Do
Case Else
Text(1).caption= "Sorry, I don't understand what you are saying. Try again "
End Select
Loop
End Sub
Go to the Hotspot Properties on the screen, and enter
- Code: Select all
If question1_ok=0 Then Question1
If question1_ok=1 Then Question2
If question1_ok=2 Then Question3
If question2_ok=1 Then Question4
If question2_ok=2 Then Question5
Now create the integer variables
question1_ok
question2_ok
question3_ok
question4_ok
I've found it pretty difficult to keep track of the questions and answers and variables