PDA

View Full Version : [SOLVED] Newbie Question



rower32
12-15-2008, 09:44 PM
Guys I was reading VBA for dummies book and trying to run this, but everytime I run I get a syntax error message. Why??? Pls help! Thanks in advance


Sub MySub()
Static Counter As Integer
Dim Msg As String
Counter = Counter + 1
Msg = “Number of executions: “ & Counter
MsgBox Msg
End Sub

lucas
12-15-2008, 09:54 PM
Something is wrong with your parenthesis in this line:


Msg = "Number of executions: " & Counter

Try this:

Sub MySub()
Static Counter As Integer
Dim Msg As String
Counter = Counter + 1
Msg = "Number of executions: " & Counter
MsgBox Msg
End Sub

rower32
12-15-2008, 10:02 PM
Thanks chief!

I think it gives me error as I copy and paste it from pdf file. It runs well now.:yes

lucas
12-15-2008, 10:10 PM
You can mark your thread solved using the thread tools at the top of the page. That way others won't waste time looking at threads that have been resolved.....