Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2011, 02:33 PM
Formulayeti Formulayeti is offline Simple VBA macro error Windows 7 64bit Simple VBA macro error Office 2007
Novice
Simple VBA macro error
 
Join Date: Nov 2011
Posts: 1
Formulayeti is on a distinguished road
Default Simple VBA macro error


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
When using either the YourName or Right or Wrong macros it doesnt skip a slide it just stays put!
can anyone help it would be much appreciated
Reply With Quote
  #2  
Old 12-09-2011, 10:02 PM
JohnWilson JohnWilson is offline Simple VBA macro error Windows 7 Simple VBA macro error Office 2010 (Version 14.0)
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
Reply With Quote
Reply

Tags
macros, simple, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VBA macro error 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft