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.
arkady5Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
cjwikConnect With a Mentor Commented:
You have to build your own function that will handel this for you. Use the instr function to help you search for commas, or maybe use the len to get hold of how long your string is and start steping throug it one step at the time.
0
 
deightonCommented:
That answers all very well, but reject it if you want because I've got the code ready for you!
 

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

0
 
deightonCommented:
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

0
All Courses

From novice to tech pro — start learning today.