Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Tutorial on Arrays
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 8th, 2003 05:25 AM    Post subject: Tutorial on Arrays Reply with quote

Arrays are simple. It can easily be described as a variable which has a bunch
of little variables inside of them, each sub variable having a serial number.
Code:
'Syntax:
Myarray(Insert any number here) = insert any value here

'Example:
Dim MyArray() As Variant 'Makes the array exist.
ReDim MyArray(1 To 3) 'States that there are 3 subvariables
MyArray(1) = "A" 'Sets subvariable '1' to "A"
MyArray(2) = "B" 'Sets subvariable '2' to "B"
MyArray(3) = "C" 'Sets subvariable '3' to "C"
MsgBox MyArray(1) & MyArray(2) & MyArray(3)
'Displays all three subvariables in one MessageBox


But know that you may use variables to define the subvariable you wish to
change or retrieve
Code:
Dim MyArray() As Variant
ReDim MyArray(1 To 3)
For i = 1 To 3
MyArray(i) = 5 * i
Next
For i = 1 To 3
MsgBox MyArray(i)
Next

But you are also capable of having an Array with more than one
"subvariable" ID number. These are called Multidimensional Arrays.
Code:
'Syntax:
Dim TimesTable() As Long
ReDim TimesTable(insert number here, insert another number here)

'Example:
Dim TimesTable() As Long
ReDim TimesTable(1 To 100, 1 To 100)
For x = 1 To 100
For y = 1 To 100
  TimesTable(x, y) = x * y
Next y
Next x

MsgBox TimesTable(InputBox("Give me a number between 1 and 100."), InputBox("Give me another number between 1 and 100."))
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic