by N. Pandu Ranga Rao. (3 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 5th March 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Converts Comma Seperated values CSV to numbers... (Example: Page number option in Printer Dialog)
API Declarations
For i = 1 To GetCSVCnt(Text1.Text)
MsgBox GetNumFromCSV(Text1.Text, CLng(i))
Next
Public Function GetNumFromCSV(Text As String, NumberCount As Integer) As Long
Dim x As String
Dim y As String
Dim z As Double
Dim i As Long, NumCnt As Integer
NumCnt = 0
z = 0
y = ""
x = ""
For i = 1 To Len(Text1)
x = Mid(Text1, i, 1)
If x = "," Or x = "-" Then
z = Val(y)
NumCnt = NumCnt + 1
If NumCnt = NumberCount Then
GetNumFromCSV = z
Exit Function
End If
z = 0
y = ""
x = ""
End If
y = y & x
x = ""
Next
z = Val(y)
GetNumFromCSV = z
End Function
Public Function GetCSVCnt(Text As String) As Integer
Dim x As String
Dim i As Long, Cnt As Integer
Cnt = 0
x = ""
For i = 1 To Len(Text1)
x = Mid(Text1, i, 1)
If x = "," Or x = "-" Then
Cnt = Cnt + 1
End If
Next
Cnt = Cnt + 1
GetCSVCnt = Cnt
End Function
No comments have been posted about Converts Comma Seperated values CSV to numbers... (Example: Page number option in Printer Dialog). Why not be the first to post a comment about Converts Comma Seperated values CSV to numbers... (Example: Page number option in Printer Dialog).