Have the following code but can only get it to work when I enter nothing into the answer box then it says sorry..... but if i enter any# or a letter it doesnt do anything.. wordpad will not accept all the end if's and else statements either. only one it allows is the end if at the end of the code. here is my code.

'************************************************************************* 
'Script Name: Mathgame.vbs 
'Author: Jerry Ford 
'Created: 02/28/02 
'Description: This script prompts the user to solve a mathematical 
'expression and demonstrates how to solve it in the event that the user 
'cannot 
'************************************************************************* 

'Initialization Section 

Option Explicit 

Dim WshShl, QuestionOne, ProveIt 

'Define the title bar message to be displayed in the script's 
'pop-up dialog 
Const cTitlebarMsg = "The Math Game" 

'Instantiate an instance of the WshShell object 
Set WshShl = WScript.CreateObject("WScript.Shell") 

'Present the player with the equation 
QuestionOne = InputBox("What is the sum of 1 + 5 * 9 / 3 ?", cTitlebarMsg) 

'See if the player provided an answer 
If Len(QuestionOne) = 0 Then MsgBox "Sorry. You must enter a number to play this game." 
WScript.Quit
End If 

'Make sure that the player typed a number 
If IsNumeric(QuestionOne) <> True Then MsgBox "Sorry. You must enter a number to play this game." 
WScript.Quit 
End If

'Check to see if the player provided the correct answer
If QuestionOne = 16 Then MsgBox "Correct! You obviously know your math!"
Else 
ProveIt = MsgBox("Incorrect. Do you want to see me solve the " & _ 
"equation?", 36, cTitlebarMsg) 


If ProveIt = 6 Then 'Player wants to see the solution 

'Start the WordPad application 

WshShl.Run "WordPad" 

'Pause script execution to give Windows enough time to load WordPad 

WScript.Sleep 2000 

'Use WordPad to show the player how to solve the equation 

WshShl.SendKeys "To answer this question you must follow the " & _ 
"correct order of precedence when performing your calculations." 

WScript.Sleep 2000 

WshShl.SendKeys "~~" 

WshShl.SendKeys "1st, working from left to right multiply 5 * 9." 

WScript.Sleep 2000 

WshShl.SendKeys "~~" 

WshShl.SendKeys "2nd, divide the result by 3." 

WScript.Sleep 2000 

WshShl.SendKeys "~~" 

WshShl.SendKeys "3rd, add 1." 

WScript.Sleep 2000 

WshShl.SendKeys "~~" 

WshShl.SendKeys "The final answer is 16." 

WScript.Sleep 2000 

WshShl.SendKeys "~~" 

WshShl.SendKeys "~~" 

WshShl.SendKeys "In case you question my math..... watch this!" 

WScript.Sleep 2000 

WshShl.SendKeys "%{F4}" 

WshShl.SendKeys "%{N}" 

'Start the Calculator application 

WshShl.Run "Calc"


'Use the Calculator application to solve the equation 

WScript.Sleep 2000 

WshShl.SendKeys 5 & "{*}" 

WScript.Sleep 2000 

WshShl.SendKeys 9 

WScript.Sleep 2000 

WshShl.SendKeys "~" 

WScript.Sleep 2000 

WshShl.SendKeys "{/}" & 3

WScript.Sleep 2000 

WshShl.SendKeys "~" 

WScript.Sleep 2000 

WshShl.SendKeys "{+}" & 1 

WScript.Sleep 2000 

WshShl.SendKeys "~" 

WScript.Sleep 2000 

WshShl.SendKeys "%{F4}" 
End If

End If

Why are you starting Wordpad?

Why are you starting Wordpad?

I meant NotePad LOL

OK. Why are you starting Notepad? :icon_rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.