Sub LoadNumbers (arr() As Integer, ByVal txt As String)
Dim pos1 As Integer
Dim pos2 As Integer
Dim txtlen As Integer
Dim num_commas As Integer
Dim num_txt As String
Dim i As Integer
' Count the commas.
num_commas = 0
pos1 = InStr(txt, ",")
Do While pos1 > 0
num_commas = num_commas + 1
pos1 = InStr(pos1 + 1, txt, ",")
Loop
' Make room for the numbers.
ReDim arr(1 To num_commas + 1)
' Read the numbers.
txtlen = Len(txt)
i = 1
pos2 = 0
Do While pos2 < txtlen
pos1 = pos2 + 1
pos2 = InStr(pos1, txt, ",")
If pos2 = 0 Then pos2 = txtlen + 1
num_txt = Mid$(txt, pos1, pos2 - pos1)
arr(i) = CInt(num_txt)
i = i + 1
Loop
End Sub
|