Link to home
Start Free TrialLog in
Avatar of arkady5
arkady5

asked on

formatting strings

If I have a string like 1,2,3,4,5,6,... how do I convert this into separate integers like 1 2 3 4 5 6 ....  So the question is how do I remove the commas and convert this string into the integers that are separated by the commas.
ASKER CERTIFIED SOLUTION
Avatar of cjwik
cjwik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That answers all very well, but reject it if you want because I've got the code ready for you!
 

That answers all very well, but reject it if you want because I've got the code ready for you!
 

Private Sub Command1_Click()

Dim i As Integer, stemp As String, sstring As String
Dim n(10) As Integer, j As Integer

i = 1

sstring = "1,2,3,4,5,6"

While i <= Len(sstring)
  If Mid(sstring, i, 1) <> "," Then
     stemp = stemp & Mid(sstring, i, 1)
  Else
     MsgBox (stemp)    'store it here
     j = j + 1
     n(j) = Val(stemp)
     stemp = ""
  End If
  i = i + 1
Wend
MsgBox stemp 'store it here
j = j + 1
n(j) = Val(stemp)


End Sub