Solved

formatting strings

Posted on 1999-01-21
4
129 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

19 Experts available now in Live!

Get 1:1 Help Now