Array Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mafaisal
    New Member
    • Sep 2007
    • 142

    Array Problem

    Hello,

    How to Declare size of array at runtime
    I mean

    Code:
    Dim Arr() as string
    Array Arr() size is How to declare Later
    Array size is varies , How to declare that in Runtime

    I tried to Declare Like
    Code:
    Dim i as integer
    i=10
    Dim Arr(i) as string
    Here Error is coming like constant expected

    Expecting reply

    Faisal

    Faisal
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Originally posted by mafaisal
    Hello,

    How to Declare size of array at runtime
    I mean

    Code:
    Dim Arr() as string
    Array Arr() size is How to declare Later
    Array size is varies , How to declare that in Runtime

    I tried to Declare Like
    Code:
    Dim i as integer
    i=10
    Dim Arr(i) as string
    Here Error is coming like constant expected

    Expecting reply

    Faisal

    Faisal
    You must be explicit in your dimensioning in VB6. You cannot use a variable, you must either use a constant:

    Code:
    Private Const MyArrayUbound = 10 
    
    Dim MyArray(MyArrayUbound) As String
    or explicitly set it:

    Code:
    Dim MyArray(10) As String

    Comment

    Working...