|
-
Apr 6th, 2004, 09:59 AM
#1
Thread Starter
New Member
newbie concatenation issues
Hi all,
I'm writing a VB program for a school project, and I have what I think is a very simple question.
I have 13 arrays, each labeled SensorArray1, SensorArray2, etc. What I want to do is make a FOR loop from i=1 to i=13 that will read or write data to the arrays. i.e. SensorArrayi = xxxxx. What is the syntax to tack that "i" on the end of SensorArray? Is it possible? please help....
Adam
-
Apr 6th, 2004, 10:11 AM
#2
Frenzied Member
Can you give some more information? like what is to be stored in the arrays? I'm thinking you should create an array called Sensors(13) and you can store your data in each of them.
OR you create your own class (what I would do) and in each sensor element, have the properties assigned.
-
Apr 6th, 2004, 10:16 AM
#3
Thread Starter
New Member
I am just storing decimal numbers in the arrays. I had an earlier problem by using a 2 dimensional array, Sensors(13, X) because I need to dynamically change the size of each array element, as these arrays hold data for a chart, and depending on the amount of data to be input will depend on the size of the array. The way I have it now works, except I'd like to save some code by just adding this "i" on the end of SensorArray, if that's possible. Thank you for your fast reply! Any more info would be great!
Adam
-
Apr 6th, 2004, 11:09 AM
#4
Frenzied Member
well, if it was ME, I would create a class, "Sensor", and give it properties:
xCoord
yCoord
at minimum.
then, you can declare an array of them:
dim Sensor(13) as Sensor
then, you could start a loop:
VB Code:
dim intCount as integer = 0
for intCount = 0 to 13
Sensor(intCount) = new Sensor
with Sensor(intCount)
.xCoord = VALUE
.ycoord = VALUE
next intCount
See how that works? Of course, you could just dim Sensor() with any number but I used 13 cause you said you had 13.
Hope that helps!!
-
Apr 6th, 2004, 11:53 AM
#5
Thread Starter
New Member
THANK YOU, THANK YOU, THANK YOU!!!! I am forever in your debt. I didn't know how to make a class before, and that makes so much sense now!! Too bad I didn't know that a few months ago when I took on this project...there's only 1 week left now. Thank you again. It works perfectly.
Adam
-
Apr 6th, 2004, 11:59 AM
#6
PowerPoster
Hi,
To answer your question, No you cannot further identify the array by trying to add a variable to the end of it.
Your previous idea of using a 2 dimension array should work OK. The varying size of the data to be input does not affect this.
As an alternative to that and Andy's suggestion, you could use a collection of the array, accessing them by way of the index property.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|