[RESOLVED] creating and using array
did a search and
i checked out "original monkey gangeter's tutorial on arrays. Followed it to the T and im not getting what i want.
from what i understand to create an array id do this
dim arrayname(#) as datatype
arrayname(0)= "whatever value i want"
arrayname(1)= "whatever i want"
... so on
this doesnt work on mine, the bottome two arrayname's would be underlined in blue and it would say "explicit initialization is nto permitted with arrays declared with excplicit bounds" i have this declared as at the module level, does it belong somehwere else?
and then
how do i specify which element in the array i want using a combo box SelectedIndexChange?
Re: creating and using array
I'm guessing that you have those lines outside of any method definition. You can declare and initialise an array outside a method, which is what your first line does, but to set individual elements you must do it inside a method. You can do this:
VB Code:
Dim myArray(upperBound) As Object
Private Sub SomeMethod()
myArray(0) = someObject
myArray(1) = someOtherObject
'...
End Sub
or this:
VB Code:
Dim myArray() As Object = {someObject, someOtherObject, ...}
Note in the second example I have not specified an upper bound. When you initialise an array at the time it's declared you cannot specify an upper bound as it is controlled by the size of the array you use to initialise it with.
Re: creating and using array
Re: creating and using array
Don't forget to resolve your thread from the Thread Tools menu if you have a satisfactory answer.