Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I test for a subscript out of range error?

Status
Not open for further replies.

bigracefan

Programmer
Apr 2, 2002
304
0
0
US
I'm spliting a file and sometimes I get a line that doesn't have all of the elements.

strValue(i, 2) = MyTempStr(1) 'Index
strValue(i, 3) = MyTempStr(2) 'Status = 0 pass, 1 fail
strValue(i, 4) = MyTempStr(3) 'Measured
strValue(i, 5) = MyTempStr(4) 'Lo Limit
strValue(i, 6) = MyTempStr(5) 'Hi Limit

How can I test to see if MyTempStr will have a value or will be give a subscript out of range.
 
If I understand you question correctly then you may want to look into the ubound command and do something like

if ubound(MyTempStr)<5 then
'Not a valid line DO SOMETHING DIFFERENT
else
'normal value
end if
 
Close. What I've resolded to do is check the number of commas before spliting it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top