Arrays in VB.Net
-
I am programing a windows app (much like my console app talked about earlier in the forums) such as this. User inputs number Number is stored into an array there are commands the user can use to print sort and other such things. I do not want to use the
arraylist
function. I want to do this using just using array as such:Dim array1(3) as string
I'm not sure how to add items to the array. In all my searching I only found information on theArraylist
. If anyone can Point me in the right direction. "Doko ni datte, hito wa tsunagatte iru." -Lain -
I am programing a windows app (much like my console app talked about earlier in the forums) such as this. User inputs number Number is stored into an array there are commands the user can use to print sort and other such things. I do not want to use the
arraylist
function. I want to do this using just using array as such:Dim array1(3) as string
I'm not sure how to add items to the array. In all my searching I only found information on theArraylist
. If anyone can Point me in the right direction. "Doko ni datte, hito wa tsunagatte iru." -LainDo you mean to assign objects to the array, simply do this
array1(0) = "Hello"
array1(1) = "world"If you mean to increase the capacity of the array, use the
Redim
keywordRedim Preserve array1(10)
array1(9) = "Bye"
Sig Under Construction. Visit back later. Support Bone
-
Do you mean to assign objects to the array, simply do this
array1(0) = "Hello"
array1(1) = "world"If you mean to increase the capacity of the array, use the
Redim
keywordRedim Preserve array1(10)
array1(9) = "Bye"
Sig Under Construction. Visit back later. Support Bone
I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(
-
I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(
Post a code snippet so we can see what you are doing. The two methods above work perfectly for String types also, so we're not getting all the details we need to know to answer your question. RageInTheMachine9532
-
Post a code snippet so we can see what you are doing. The two methods above work perfectly for String types also, so we're not getting all the details we need to know to answer your question. RageInTheMachine9532
So you're looking to dynamically increase the size of the array? If so, the earlier suggestion of
Redim
should work for you. You may want to look at theArrayList
class in the .Net Documentation anyway - theAdd
method makes it easy to work with a dynamically increasing list, and there areCopyTo
andToArray
methods if you need to convert it to an actualArray
object. -
I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(