Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

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.
0
arkady5
Asked:
arkady5
  • 3
1 Solution
 
cjwikCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now