a problem in array in vb.net
-
i use arrays in vb.net but i have a problem in the dimension ex : dim a() as integer a(0)=new integer gives error i don't want to use arraylist because i dound inutil to do the cast
-
i use arrays in vb.net but i have a problem in the dimension ex : dim a() as integer a(0)=new integer gives error i don't want to use arraylist because i dound inutil to do the cast
-
Could you display your real code please? What are you really setting a(0) equal to? I mean, you are not actually setting it to New Integer right? You are setting it to an actual value? And what is the error that you are getting?
i'm defining a vector without defining its size so when i make new to allocate in memory i get the eror : not set to an instance
-
i use arrays in vb.net but i have a problem in the dimension ex : dim a() as integer a(0)=new integer gives error i don't want to use arraylist because i dound inutil to do the cast
-
i'm defining a vector without defining its size so when i make new to allocate in memory i get the eror : not set to an instance
I haven't been able to get through this error without defining the size of the array upfront. If you are using Visual Studio 2005 you can use a List object instead. It is like an ArrayList except that you must declare what type of objects are being listed, so you will not have to worry about the overhead of casting the objects into what you want. Here's how you declare it:
Dim objList As New List(Of Integer)
Hope this helps. -
thanks that's work now i have a bigger question if a fuction return a vector public function f() as integer () dim a() as integer redim preserve a(0) redim preserve a(1) a(0)=1 a(1)=0 return a end function ----------------------------------- dim k () as integer k=f() msgbox(k(0)) ------->gives error : not set to instance
-
thanks that's work now i have a bigger question if a fuction return a vector public function f() as integer () dim a() as integer redim preserve a(0) redim preserve a(1) a(0)=1 a(1)=0 return a end function ----------------------------------- dim k () as integer k=f() msgbox(k(0)) ------->gives error : not set to instance
- if you know how many you'll have you can do a 'static' array dim a(1) as integer 'creates 0 both instances 0 and 1 2) you don't need to do a redim twice if you know how big you want to make it. redim preserve a(1) 'will create both instances 0 and 1 3) ran you code... ran fine for me...???
-
- if you know how many you'll have you can do a 'static' array dim a(1) as integer 'creates 0 both instances 0 and 1 2) you don't need to do a redim twice if you know how big you want to make it. redim preserve a(1) 'will create both instances 0 and 1 3) ran you code... ran fine for me...???
man thanks but the problem is when the functon return the vector ... it allways be null
-
man thanks but the problem is when the functon return the vector ... it allways be null