If I declare an array like this
Dim sKeyArray() as String
how can I know if the array is set or not, eg
MsgBox sKeyArray(0) returns Subscript out of range
but if I later in the program
sKeyArray = frmMain.fnReturn_Array
Then the array is set and everyting works.
But before its set how can I check if its empty or not?
Regards
Fredrik
Fredrik Melin wrote:
--
Laura Meyerovich
Magnet Systems
phone (401) 742-1636
fax (520) 438-5537
lmeye...@home.com
Visual Basic, MS Access, Crystal Reports, SQL Server, and ASP
independent consultant.
Development, system integration, database design and data conversions.
This also generates the same error for an undimensioned dynamic array.
Having wrestled with this, I have concluded that it is best to just redim
the array to (0) immediately after declaring it.
Public Function IsDimmed(anArray As Variant) As Boolean
Dim i As Long
On Error GoTo IDErr
i = LBound(anArray)
IsDimmed = True
Exit Function
IDErr:
IsDimmed = False
Exit Function
End Function
e.g.
Private Sub Command1_Click()
Dim Arr() As Integer
MsgBox IsDimmed(Arr)
ReDim Arr(0)
MsgBox IsDimmed(Arr)
End Sub
Not elegant but it works.
Simon Smith
www.quintuslink.com
Simon at Quintuslink dot com