Adding a number to a variable title

15 pts.
Tags:
Software development
Variables
I am writing a program at work to help me design some irrigation equiptment. I have a section where I select which number span I am working on and then set it's dia. with a drop combobox and then it's length with a drop combobox. the values of these comboboxes are to go into labels so the user can see the the machine as it's built. The labels are named dia1, dia2 ..... length1, length2 ..... what I would like to do to save time and space, is for when I press the command button to store the values, it hooses the label to put it in via the span number ie; span #1 Dia Length 1 168 50.00 this is the layout. what i need is something like dia(spanno)=dia ' to load dia at span no location with the value of combobox dia length(spanno)=length ' to load length at span no location with the value of combobox length. I know i sounds confusin, and I have treid to explain it in the best way I can. I would really appreciate any help I can get.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Sounds like an array would do the trick here — or a vector or adjustable-length array, depending on the language that you’re using. But basically, you want to create an array called dia with at least (spanNo_MAX) elements, and then reference dia (and the same for length).

********

If you are using Visual Basic, you could define a type like this:

<pre>Private Type span
dia As Integer
length As Integer
End Type</pre>

and then define an array of this type, this way:

<pre>Dim Spans(100) As span</pre>

You can then use it this way:

<pre>
Spans(1).dia = 5
Spans(1).length = 10</pre>

In this example we are assigning values to the position 1 in the array (i.e spanno = 1)

Hope this helps.

-Carlosdl

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Yes, I think an array is what Angelus needs to use. More help could be provided if more details were available (at least, programming language). Regards,
    69,160 pointsBadges:
    report
  • Angelus1965
    My apologies for not including this in my main question. I am using visual basic to program with.
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following