![]() |
|
|
|
#1
|
|||
|
|||
|
i have written some simple code in vba :
Code:
Dim numberCorrect As String
Dim UserName As Integer
Dim numberWrong As String
Sub YourName()
UserName = InputBox(Prompt:="Type Your Name")
MsgBox " Welcome to the Quiz " + UserName, vbApplicationModal, " Quiz"
End Sub
Sub Correct()
MsgBox " That is correct, move on " + UserName, vbApplicationModal, " Quiz"
numberCorrect = numberCorrect + 1
SlideShowWindows(1).View.Next
End Sub
Sub Wrong()
MsgBox " Sorry Thats the wrong answer " + UserName, vbApplicationModal, " Quiz"
numberWrong = numberWrong + 1
SlideShowWindows(1).View.Next
End Sub
Sub Start()
numberCorrect = 0
numberWrong = 0
YourName
SlideShowWindows(1).View.Next
End Sub
Sub Results()
MsgBox ("You Got " & numberCorrect & " out of " & numberWrong + numberCorrect & ", " & UserName), vbApplicationModal, " Quiz "
SlideShowWindows(1).View.Next
End Sub
can anyone help it would be much appreciated |
|
#2
|
|||
|
|||
|
You need to change a couple of things
NumberCorrect and Number Wrong should be declared as Integer not String UserName is a String not an Integer In all the MsgBox lines change + to & Code:
Dim numberCorrect As Integer
Dim UserName As String
Dim numberWrong As Integer
Sub YourName()
UserName = InputBox(Prompt:="Type Your Name")
MsgBox " Welcome to the Quiz " & UserName, vbApplicationModal, " Quiz"
End Sub
Sub Correct()
MsgBox " That is correct, move on " & UserName, vbApplicationModal, " Quiz"
numberCorrect = numberCorrect + 1
SlideShowWindows(1).View.Next
End Sub
Sub Wrong()
MsgBox " Sorry Thats the wrong answer " & UserName, vbApplicationModal, " Quiz"
numberWrong = numberWrong + 1
SlideShowWindows(1).View.Next
End Sub
Sub Start()
numberCorrect = 0
numberWrong = 0
YourName
SlideShowWindows(1).View.Next
End Sub
Sub Results()
MsgBox ("You Got " & numberCorrect & " out of " & numberWrong + numberCorrect & ", " & UserName), vbApplicationModal, " Quiz "
SlideShowWindows(1).View.Next
End Sub
|
|
| Tags |
| macros, simple, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Runtime Error 4120 in Word 2007 macro
|
Frankwlc | Word | 5 | 11-28-2011 01:54 AM |
| Macro Error 5174 | muster36 | Word VBA | 0 | 08-12-2011 03:34 AM |
| Simple or what? | nebb | Publisher | 0 | 09-23-2010 07:00 AM |
| Simple template | kieransymes | Word | 0 | 03-08-2010 02:13 AM |
| Simple macro undoable? | garon5 | Outlook | 0 | 04-20-2007 10:27 AM |