|
-
Jul 10th, 2006, 07:00 AM
#1
Thread Starter
New Member
Parse into array
Hi!
I've got this as a string:
Code:
200201 +0.600000000000000E+02
200202 +0.290000000000000E+02
200203 +0.430000000000000E+02
200204 +0.760000000000000E+02
200205 +0.590000000000000E+02
200206 +0.660000000000000E+02
200207 +0.500000000000000E+02
200208 +0.660000000000000E+02
200209 +0.750000000000000E+02
200210 +0.880000000000000E+02
200211 +0.720000000000000E+02
I want to put this into a 2dim array.
With [date] and then [value]
[0][0] = 200201,
[0][1] = +0.600000000000000E+02
and so on..
Thanks for help!
-
Jul 10th, 2006, 07:12 AM
#2
Frenzied Member
Re: Parse into array
VB Code:
'from the top of my head
'suppose u already have the result in a string variable called strResult
'the final 2 dim array will be called fResult
dim fResult() as String
dim tmpMainResult() as String
dim tmpBrokenResult() as String
dim tmpcnt as integer
tmpMainResult=split(strResult,vbcrlf)
redim fResult(ubound(tmpMainResult),1) as String
for tmpcnt=0 to ubound(tmpMainResult)
tmpBrokenResult=split(tmpMainResult(tmpcnt)," ")
fResult(tmpcnt,0)=tmpBrokenResult(0)
fResult(tmpcnt,1)=tmpBrokenResult(1)
next tmpcnt
-
Jul 10th, 2006, 07:39 AM
#3
Re: Parse into array
or you could use a custom type:
VB Code:
Private Type MYDATA
dteDate As Date
dblValue As Double
End Type
Private Sub Command1_Click()
Dim arrData() As MYDATA, sTemp() As String, N As Long
sTemp = Split(Text1.Text, vbCrLf)
ReDim arrData(UBound(sTemp))
For N = 0 To UBound(sTemp)
arrData(N).dteDate = Mid$(sTemp(N), 1, 2) & "/" & _
Mid$(sTemp(N), 3, 2) & "/" & _
Mid$(sTemp(N), 5, 2)
arrData(N).dblValue = CDbl(Mid$(sTemp(N), 8))
Next N
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|