Results 1 to 4 of 4

Thread: ReDim simple problem...

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question

    hi all...
    when I use ReDim an array in Command1_Click I use it anymore in Command2_Click. How could I use it?
    I'm using this code:
    Code:
    Dim F As Integer
    
    Private Sub Command1_Click()
      F = Val(Text1.Text) 'F is bigger than 3 for sure
      ReDim a(1 To F) As String
      a(3) = "Please! be saved!"
    End Sub
    
    Private Sub Command2_Click()
      MsgBox a(3)
    End Sub
    You see, everything works fine when I'm processing the Command1_Click, but when I come to Command2, I get the "a" variable highlighted, and error that says: "Sub or Function not defined"

    Any idea so I'll be able to use the array in any procedure at the form?

  2. #2
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    Did you remember to declare the a Array as public? What is it's scope?

    How and where is it being declared?

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    just add dim a() as Integer underneath dim F as integer.

    Write Option Explicit at the Top of the Code and it'll force you to declare all your variables, that way you won't get problemms like this.

  4. #4

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Thanks

    Thanks Sam.
    It worked.

Posting Permissions

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



Click Here to Expand Forum to Full Width