/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
How Can I Know the dimensions of arrays di~
Fra : pippo


Dato : 20-11-02 12:01

I.E. How I chek if array dinamic is located.

DIM arr() Long
if (Ubound(arr)) then '<<<< Error. Ho not is dimensionate with REDIM

-------------------------------------------------
At me not LIKE the management Errors (On Error ) of VB.
-------------------------------------------------

Alfonso.




 
 
John Doe (21-11-2002)
Kommentar
Fra : John Doe


Dato : 21-11-02 14:28

A dirty "hack" is to make a function which tests the array

if not dim - then return -1

like this

Option Explicit

Private Sub Form_Load()

Dim arr() As Long
'ReDim Preserve arr(10)
MsgBox TestArray(arr)

End Sub

Function TestArray(vArr() As Long) As Integer

Dim i As Integer

On Error Resume Next ' turn off errorchecking
i = UBound(vArr)
If Err <> 0 Then 'Array is not dim
i = -1
Err.Clear ' clean up
End If
On Error GoTo 0 'turn on normal errorchecking
TestArray = i

End Function



"pippo" <pippo@iol.it> wrote in message
news:KXJC9.42856$Yw.2017031@news2.tin.it...
> I.E. How I chek if array dinamic is located.
>
> DIM arr() Long
> if (Ubound(arr)) then '<<<< Error. Ho not is dimensionate with REDIM
>
> -------------------------------------------------
> At me not LIKE the management Errors (On Error ) of VB.
> -------------------------------------------------
>
> Alfonso.
>
>
>



pippo (22-11-2002)
Kommentar
Fra : pippo


Dato : 22-11-02 10:51

Tank You, but I don't like managente Error On Error. I can chek the memory
pointer?.



"John Doe" <john@doe.com> ha scritto nel messaggio
news:arin1t$n3g$1@news.net.uni-c.dk...
> A dirty "hack" is to make a function which tests the array
>
> if not dim - then return -1
>
> like this
>
> Option Explicit
>
> Private Sub Form_Load()
>
> Dim arr() As Long
> 'ReDim Preserve arr(10)
> MsgBox TestArray(arr)
>
> End Sub
>
> Function TestArray(vArr() As Long) As Integer
>
> Dim i As Integer
>
> On Error Resume Next ' turn off errorchecking
> i = UBound(vArr)
> If Err <> 0 Then 'Array is not dim
> i = -1
> Err.Clear ' clean up
> End If
> On Error GoTo 0 'turn on normal errorchecking
> TestArray = i
>
> End Function
>
>
>
> "pippo" <pippo@iol.it> wrote in message
> news:KXJC9.42856$Yw.2017031@news2.tin.it...
> > I.E. How I chek if array dinamic is located.
> >
> > DIM arr() Long
> > if (Ubound(arr)) then '<<<< Error. Ho not is dimensionate with REDIM
> >
> > -------------------------------------------------
> > At me not LIKE the management Errors (On Error ) of VB.
> > -------------------------------------------------
> >
> > Alfonso.
> >
> >
> >
>
>



Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408925
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste