ReDim in MyArray 
Author Message
 ReDim in MyArray

I have this problem
I had declared an Array that i want to encrise....
this is the code
Dim MyArray() As Double

If MyArray.GetLowerBound(0)=0 Then

    ReDim Preserve MyArray(5)

Endif

where i process

If MyArray.GetLowerBound(0)=0 Then

i found an error .. how i can test when my array have no elements ??

Thanks



Tue, 26 Apr 2005 22:36:25 GMT  
 ReDim in MyArray
It's the same..
it's no correct...  have you another solution ??



Quote:
> Please try:

> UBound(MyArray)

> or

> MyArray.GetUpperBound

> HTH



> > I have this problem
> > I had declared an Array that i want to encrise....
> > this is the code
> > Dim MyArray() As Double

> > If MyArray.GetLowerBound(0)=0 Then

> >     ReDim Preserve MyArray(5)

> > Endif

> > where i process

> > If MyArray.GetLowerBound(0)=0 Then

> > i found an error .. how i can test when my array have no elements ??

> > Thanks



Tue, 26 Apr 2005 23:10:19 GMT  
 ReDim in MyArray
this is what i use:

try
  i = ubound(myarray)
catch
  i=0
end try


Quote:
> It's the same..
> it's no correct...  have you another solution ??



> > Please try:

> > UBound(MyArray)

> > or

> > MyArray.GetUpperBound

> > HTH



> > > I have this problem
> > > I had declared an Array that i want to encrise....
> > > this is the code
> > > Dim MyArray() As Double

> > > If MyArray.GetLowerBound(0)=0 Then

> > >     ReDim Preserve MyArray(5)

> > > Endif

> > > where i process

> > > If MyArray.GetLowerBound(0)=0 Then

> > > i found an error .. how i can test when my array have no elements ??

> > > Thanks



Tue, 26 Apr 2005 23:26:17 GMT  
 ReDim in MyArray

Quote:
> I have this problem
> I had declared an Array that i want to encrise....
> this is the code
> Dim MyArray() As Double

> If MyArray.GetLowerBound(0)=0 Then

>     ReDim Preserve MyArray(5)

> Endif

> where i process

> If MyArray.GetLowerBound(0)=0 Then

> i found an error .. how i can test when my array have no
> elements ??

> Thanks

You do not even have an array. You only declared an array variable but never
assigned a new object.

To test if you've already assigned an array to MyArray:
    If MyArray Is Nothing
If it is not Nothing, you can use MyArray.Getupperbound(0).
To create a new array, use Redim. If there are startup values for the array,
you can also use
   MyArray = new Double() {1, 2, 3}

Armin



Tue, 26 Apr 2005 23:26:15 GMT  
 ReDim in MyArray
Please try:

UBound(MyArray)

or

MyArray.GetUpperBound

HTH


Quote:
> I have this problem
> I had declared an Array that i want to encrise....
> this is the code
> Dim MyArray() As Double

> If MyArray.GetLowerBound(0)=0 Then

>     ReDim Preserve MyArray(5)

> Endif

> where i process

> If MyArray.GetLowerBound(0)=0 Then

> i found an error .. how i can test when my array have no elements ??

> Thanks



Tue, 26 Apr 2005 22:49:51 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to ....Dropdown.list()=Myarray ?

2. clarify understanding on redim statement with dynamic arrays

3. ReDim Preserve a multi column array

4. more bizarre errors (ReDim statement)

5. Problem With ReDim and With

6. REDIM on a multi-dimensional array

7. Redim an Array in VBScript

8. Redim preserve

9. redim array

10. ReDim Preserve takes ages in VB .NET

11. ReDim with 2-dimensional array

12. Redim Preserve

 

 
Powered by phpBB® Forum Software