Thu Feb 13, 2003 9:34 am
"subscript out of range" means that you are tying to access an array element that isn't dimensioned, in this case arStringArray(8) when your array has been defined to only inlcude 8 parts: 0-7. Remember that, unless otherwise defined as having a base of 1, the first element in an array starts at zero.
So, most likely, you are either not defining your array correctly or not incrementing your array correctly (i = i + 1 inside the loop). Print out what
Chances are, your translation has probably already been done. It may already be a function.
If you are translating a binary string, do you start from the front (left) or the back (right)?
There is a problem with this line:
if len(sTempString) > 8 then sStringArray = mid(sStringArray, iStringLength)
first of all it should be
if len(sTempString) > 8 then sString = mid(sString, iStringLength)
in order to redefine the string itself, therefore the string gets shorter with every iteration of the loop. Second, it doesn't redefine sString on the last time through the loop, and it should, or the loop will never end. So, try
if len(sTempString) > 8 then
'redefine string
sString = mid(sString, iStringLength)
else
'we're done
sString = ""
end if
That's what you get for copying code from a forum.
You're doing it the hard way. I suggest searching for a function that already does what you want. For example, the split function will turn a delimited string into an array. You redefine your string to have delimiters and use it, but I'll bet there's a binary string translation function out there.