Privateer
Registered User.
- Local time
- Today, 12:54
- Joined
- Aug 16, 2011
- Messages
- 193
I need some help with arrays. I am passing strings of different lengths, and the code is blowing up when the last element is empty. In other words, an array expecting seven elements is only getting six, or five. And to be clear, it all works fine when there are seven.
I have a string that is composed of values separated by a semi-colon. The number of values can vary, not by much, but 5 or 6 or 7. I am passing this string to a function that is splitting the values into a one-dimensional array of 7 as string. I have tried using Nz() around the last element, didn't work. The UBound() always says 6, which means seven and that didn't help because I am building that array with (0 to 6) dimensions.
What I would like is a way to build the array that is dynamic enough to handle a varying number of elements. I have seen the ReDim Preserve code, I just can't figure out how to get the upper number. I even considered counting how many semi-colons are in the source string and realized how nuts that sounded. Any help would be appreciated.
Thanks.
I have a string that is composed of values separated by a semi-colon. The number of values can vary, not by much, but 5 or 6 or 7. I am passing this string to a function that is splitting the values into a one-dimensional array of 7 as string. I have tried using Nz() around the last element, didn't work. The UBound() always says 6, which means seven and that didn't help because I am building that array with (0 to 6) dimensions.
What I would like is a way to build the array that is dynamic enough to handle a varying number of elements. I have seen the ReDim Preserve code, I just can't figure out how to get the upper number. I even considered counting how many semi-colons are in the source string and realized how nuts that sounded. Any help would be appreciated.
Thanks.