Consulting

Results 1 to 4 of 4

Thread: Newbie Question

  1. #1
    VBAX Newbie
    Joined
    Dec 2008
    Posts
    2
    Location

    Newbie Question

    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

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Newbie
    Joined
    Dec 2008
    Posts
    2
    Location
    Thanks chief!

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

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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.....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •