How to learn ARRAY please..???
Dear Experts,
I am a VB newbie and just very the beginner...anyone knows the sources to learn ARRAYS please..???..the logic, theory and practicals..??
Additionally, what is the best source to learn Visual Basic please..???
Thanks a lot for your help..
Jennifer ;)
Re: How to learn ARRAY please..???
In the FAQs Forum you'll find an Arrays Tutorial by EyerMonkey
Here is
Re: How to learn ARRAY please..???
The best way of learning visual basic, in my opinion, is being on these forums. If you go through and read some of the posts of code, you will learn a lot more than you would through a book. Because a book may have one expert, but here we have hundreds ;)
excluding me of course from the experts section :lol:
Re: How to learn ARRAY please..???
Zach, you don't have to post in these forums like it's an email. Just pretend you are talking like a normal person.
The best way to learn VB is not so much the tutorials, forums, source code, and books, but mostly coding on your own. It's all about patience, and using logic. That's after you learn the basics of course.
And to help solve your array problem, arrays are like variables, only they are somewhat like using multiple variables with the same name. Like for example:
You now have an array called MyArray with 10 elements. Why 10 you ask? Because the elements range from 0 - 9. And if you count them, you will see that there are 10. You use the array like so, after declaring it:
VB Code:
Private Sub Form_Load()
Dim MyArray(9) As Long
MyArray(0) = 1
MyArray(1) = 3
MyArray(2) = 5
MsgBox MyArray(0)
End Sub
Another cool thing you can do to arrays is this:
VB Code:
Private Sub Form_Load()
Dim MyArray() As Long 'No elements specified
ReDim MyArray(9) As Long 'Now it has 10 elements
End Sub
This comes in handy incase you don't know how many elements your array is gonna get. But this technique can erase all the data that was in your array. Here is what I mean:
VB Code:
Private Sub Form_Load()
Dim MyArray() As Long 'No elements specified
ReDim MyArray(9) As Long 'Now it has 10 elements
MyArray(0) = 10
ReDim MyArray(5) as Long
MsgBox MyArray(0)
End Sub
The output will be 0, cause it erased the entire array after it has been Redimensioned. So what you can do about this is use ReDim Preserve, so the data doesn't get erased:
VB Code:
Private Sub Form_Load()
Dim MyArray() As Long 'No elements specified
ReDim MyArray(9) As Long 'Now it has 10 elements
MyArray(0) = 10
ReDim Preserve MyArray(5) as Long 'Data has been preserved
MsgBox MyArray(0)
End Sub
And you should get 10 as a result. Also note that the arrays are linear in memory, and can come in handy working with the memory portion of them once you learn how to work with pointers. ;)