
String part II - Thank you.
The following would work with any number of number groups in the string -
held in an array for ease of use
HTH, Neil - UK
Option Explicit
Dim MyString, MyArray, Index
MyString = "+12+1234+123+1+123+1235+234+2341+999"
' Strip leading '+' if present otherwise first array element would be 0
If Left(MyString,1)="+" Then MyString=Mid(MyString,2)
' Split MyString using '+' as de-limiter, returning all instances,
performing a textual comparison
MyArray = Split(MyString,"+", -1 ,1)
' Work through array padding values with 0's
For Index=0 to Ubound(MyArray)
MyArray(Index)=Right("0000" & MyArray(Index),4)
WScript.Echo MyArray(Index) ' Rem this line - display
purposes only
Next
Quote:
> I have a string :
> String = "+12+1234+123+1+23" '+ sign is my break point between
the
> numbers. Number of integers between +'s can be different.
> How can I break it down and assign to variables to get:
> strA = 0012
> strB = 1234
> strC = 0123
> strD = 0001
> strE = 0023
> I always want to have 4 digits (zeros as leading numbers)
> Thanks for help.