Inputing variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all. I have an input which will have 1 or 3 variables in it, all
seperated by a ",". It would look like this "2000" or "2000, 500, 3000" The
values are the conditions for a loop: the start, step and ending value. I
was trying to read it in using this code.
Holding = Split(I_Wt_Value, ",")
Weight(0) = Holding(0)
Weight(1) = Holding(1)
Weight(2) = Holding(2)
If IsEmpty(Weight(1)) Then
Weight(3) = 0
Weight(2) = Weight(0)
Weight(1) = Weight(0)
Else
Weight(3) = Weight(0) - Weight(1)
End If

The idea was to take the holding value and put it into an array since I
could use it a little easier but if there is one value instead of 3 in the
field, it spits out a "subscript out of range" error. I need to be able to
use it for both of those inputs I have earlier. Any ideas?

Thanks!
 
if(instr(I_Wt_Value,",") = 0 then
I_Wt_Value = I_Wt_Value & ",0,0"
End if
Holding = Split(I_Wt_Value, ",")
Weight(0) = Holding(0)
Weight(1) = Holding(1)
Weight(2) = Holding(2)
If IsEmpty(Weight(1)) Then
Weight(3) = 0
Weight(2) = Weight(0)
Weight(1) = Weight(0)
Else
Weight(3) = Weight(0) - Weight(1)
End If

Or concatenate whatever is appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top