473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

bamos!, can someone help me with arrays....PLz.........

knychtell
Good day to you, im a junior here, i wonder if someone could help me about arrays.... i just need a brief instruction of what an array is and its uses, i already have several books but it dont say much about it i have samples but it's quite hard to anlyze it thanks guys.... i really need this, im having my midterm exams soon ... thanks a lot,
Jan 17 '07 #1
2 1182
Dököll
2,364 Expert 2GB
Ola!

Let's start small, I will be referring to books I have here to make sure it makes sense:

You can look at an array as a street name with a number of houses on that street. Say it were Text1, as the name of your street and there are 4 houses on Text1, the four houses are therefore elements of Text1 (part of Text1) where Text1 is a container that holds 4 houses

These houses are numbered as 0, 1, 2, 3, thus House number 0 is part of Text1, number 1, and so on all part of Text1...

Each house however is unique, they do not have the same number

numbers 0, 1, 2, and 3

In other to distinguish between these Text1 houses, you would need to go by their number.

VB has a wonderful way of asking you if you need to create an array...If you are creating a TextBox array, your array namely, Text1, you can drag Text1 to your form and copy that TextBox. When you attempt to paste, VB will ask you if you need this as an array, say Yes, then paste 3 additional TextBoxes to your form. They should be available to your upper Left corner, on top of one another, just drag an position where you need them. They should be named as the following:

Text1(0) 'for house number 1
Text1(1) 'for house number 2
Text1(2) 'for house number 3
Text1(3) 'for house number 4

Because VB considers 0 as a variable, it too must be counted, thus calcultated as first position. You can change Text1(0) to Text1(1), if you prefer and to keep it simple:


Text1(1) 'for house number 1
Text1(2) 'for house number 2
Text1(3) 'for house number 3
Text1(4) 'for house number 4

Hopefully you get it from here, if not please write again.

Dököll
Jan 18 '07 #2
Killer42
8,435 Expert 8TB
I'll attempt a slightly simpler explanation, just in case you didn't quite get it from that one.

I'll assume you have encountered variables, and have some idea of what they are for.

Let's say you have a hundred variables, holding the same piece of information about a hundred objects. You decide that for whatever reason, you need to add 1 to each of them.

Using individual variables, you would have to write a hundred lines of code.
Expand|Select|Wrap|Line Numbers
  1. Variable1 = Variable1 + 1
  2. Variable2 = Variable2 + 1
  3. Variable3 = Variable3 + 1
  4. .
  5. .
  6. .
  7. Variable100 = Variable100 + 1
You can see that this would quickly make your code too long and cumbersome to work with. Plus you would have to know, when writing the code, how many objects there will be.

An array, on the other hand, looks kind of like one variable, but you use an index to refer to multiple "instances" of it, which can hold different values. That means you can do neat things like using loops. To take the same example of modifying 100 objects from above...
Expand|Select|Wrap|Line Numbers
  1. For Index = 1 To 100
  2.   ArrayVariable(Index) = ArrayVariable(Index) + 1
  3. Next
I'm sure you'll agree that three lines of code are much easier to read (and type). And for all sorts of reasons, this is much more flexible. For example, the "1" and "100" limits on this loop could be values from other variables, so they can change while the program is running, without having to rewrite the code.
Jan 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: DigitalCaliberSlave | last post by:
What I have is a form with a picturebox. The picturebox is maximized to the size of the window.. This picturebox, inturn, has within it's borders, a possible 4 other pictureboxes. (...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.