Results 1 to 11 of 11

Global Array not working

Threaded View

Pergo Global Array not working 08-30-2012, 09:05 AM
shg Re: Global Array not working 08-30-2012, 09:09 AM
JosephP Re: Global Array not working 08-30-2012, 09:24 AM
Pergo Re: Global Array not working 08-30-2012, 09:40 AM
JosephP Re: Global Array not working 08-30-2012, 09:43 AM
shg Re: Global Array not working 08-30-2012, 09:49 AM
Pergo Re: Global Array not working 08-30-2012, 09:51 AM
shg Re: Global Array not working 08-30-2012, 09:54 AM
JosephP Re: Global Array not working 08-30-2012, 10:02 AM
shg Re: Global Array not working 08-30-2012, 10:03 AM
Pergo Re: Global Array not working 08-30-2012, 10:25 AM
  1. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Global Array not working

    Just to repeat,

    You can't declare a public variable in any procedure, and you can't declare a public variable in a class module (sheet module, ThisWorkbook, form, user-defined class).

    Public variables must be declared at the top of a standard module, above any procedures, right below Option Explicit.

    Option Explicit
    
    Public iJob         As Integer
    Const iMax          As Long = 15
    Public asJob(1 To iMax) As String
    
    Sub x()
        asJob(1) = "Bob"
        MsgBox asJob(1)
    End Sub
    Last edited by shg; 08-30-2012 at 10:00 AM.

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