Results 1 to 6 of 6

Thread: newbie concatenation issues

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    3

    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

  2. #2
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    3
    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

  4. #4
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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:
    1. dim intCount as integer = 0
    2.  
    3. for intCount = 0 to 13
    4.    Sensor(intCount) = new Sensor
    5.     with Sensor(intCount)
    6.         .xCoord = VALUE
    7.         .ycoord = VALUE
    8. 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!!

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    3
    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

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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
  •  



Click Here to Expand Forum to Full Width