How to Dim a 2-dimensional array with....

MikeLI

Member
Joined
Dec 28, 2005
Messages
8
Programming Experience
Beginner
Hi All,

I would like to ask:
How to Dim a 2-dimensional array with the first column is string, and the second column is integer? such as:

array(26, 2) = {("Apple", 11), ("Bee", 42), ("Cow", 23), ("Dog", 54)...., ("Zip", 216)}


Mike
 
Any object can only be declared as a single type. If you need that type to be a user defined one that consist of several different valuetypes, you define a structure or a class. Example, I also added a method, this is allowed:
VB.NET:
Structure twos
 Dim integ As Integer
 Dim str As String
 
 Sub showmeoff()
  MessageBox.Show("me.integ is '" & Me.integ _
  & "' and me.str is '" & Me.str & "'")
 End Sub
End Structure
Then you can declare a 27 elements array of this type:
VB.NET:
Dim ArrayOfTwos(26) As twos
Later a value can be set so for element 21, and displayed using the showmeoff method:
VB.NET:
ArrayOfTwos(20).integ = 1836237
ArrayOfTwos(20).str = "abc"
[SIZE=2]ArrayOfTwos(20).showmeoff()
[/SIZE]
 
Back
Top