r/vbscript • u/SCHMIDTHe4D • Jan 26 '15
I'm new to VBScript. Help!
Ok, I'm taking a programing class in college and I can't get the Knock knock game to get past who's there, I keep getting incorrect answer please try again. any ideas? I'll paste what I've done below. Thanks!
Replyl = Inputbox("Knock Knock!") If Reply1 = "who's there?" Then Reply2 = InputBox("Panther!") If Reply2 = "Panther who?" Then _ MsgBox "Panther or no panths I'm going swimming." If Reply2 <> "Panther who?" Then MsgBox "Incorrect answer. Try again." End If If Reply1 <> "who's there?" Then MsgBox "Incorrect answer. Try again."
2
Upvotes
3
u/[deleted] Jan 26 '15 edited Jan 26 '15
Would you like the correct answer or tips for figuring out the correct answer ? Tall_pat I can tell you that your code will not work. You have an end if that quits the code half way through. Also other issues with else if sections. I take that back Tall-pat... your code does work... just not how I would have done it ;) I would have nested the Reply2 code entirely in the first if statement.
2
u/tall_pat Jan 26 '15
I'm only about 3 weeks into learning VBScript myself, so my answer may not be the most elegant solution, but I got this to work with the following:
Of course, the answers that the user provides to the input boxes must be identical to the supplied values (including exact capitalization and punctuation) in order for the statements to evaluate as "True".