Solved

formatting strings

Posted on 1999-01-21
4
131 Views
Last Modified: 2010-05-03
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
Comment
Question by:arkady5
  • 3
4 Comments
 
LVL 2

Accepted Solution

by:
cjwik earned 10 total points
ID: 1469878
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
 
LVL 18

Expert Comment

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

0
 
LVL 18

Expert Comment

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

0
 
LVL 18

Expert Comment

by:deighton
ID: 1469881
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now