+ Reply to Thread
Results 1 to 2 of 2

Can Const be defined once in one Sub?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2007
    Posts
    1

    Can Const be defined once in one Sub?

    Can Const be defined once in one Sub in the same Module1? For example, instead of defining the same Const Count below, I just want to define it once and use it for both subs. I tried Public Const but gave error: Invalid attribute for sub or function.

    
    Sub Test()
    Const COUNT = 10
    End Sub
    
    Sub Test2()
    Const COUNT = 10
    End Sub
    Thanks for help.

  2. #2
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Yes, if you define it before your first sub it can be use by all the subs below that.
    Const Count = 10
    Sub Test()
       code
    End Sub
    
    Sub Test2()
        code
    End Sub
    Sincerely,
    Jeff

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1