|
-
Jul 14th, 2002, 11:33 PM
#1
Thread Starter
New Member
String Data Parser
i am trying to make a simple program which will take a string with information "Name, age; Name, age; " and so on and will move it into an array of a data structure called Person (containing Name, age) any idea of how a loop that does that would look like?
-
Jul 14th, 2002, 11:36 PM
#2
The picture isn't missing
Dim Person() as String
Person = Split("George, 20; Frank, 99;Egads, 9999898",";")
puts the string into the array, as you said.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 11:40 PM
#3
Thread Starter
New Member
what i meant is that person is a data structure such as this:
Public Structure Person
Dim Name as String
Dim Age as integer
-
Jul 14th, 2002, 11:40 PM
#4
Thread Starter
New Member
what i meant is that person is a data structure such as this:
Public Structure Person
Dim Name as String
Dim Age as integer
end structure
-
Jul 14th, 2002, 11:41 PM
#5
The picture isn't missing
there's no such thing. do you mean UDT?
Private Type Person
Name as String
Age as Integer
End Type
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 11:43 PM
#6
Thread Starter
New Member
well yeah ( itz just thats the way it iz on .Net)
-
Jul 14th, 2002, 11:48 PM
#7
The picture isn't missing
VB Code:
Private Type Person
Name As String
Age As Integer
End Type
Option Explicit
Private Sub Form_Load()
Dim Persons() As Person
Dim Temp() As String
Dim Temp2() As String
Dim i As Long
Temp = Split("George,20; Frank,99;Egads,9999898", ";")
For i = LBound(Temp) To UBound(Temp)
Temp2 = Split(Temp(i), ",")
On Error Resume Next
ReDim Preserve Persons(UBound(Persons) + 1)
If Err Then ReDim Preserve Persons(0)
Persons(UBound(Persons)).Name = Temp2(0)
Persons(UBound(Persons)).Age = Temp2(1)
Next i
MsgBox Persons(1).Name
End Sub
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 11:49 PM
#8
Thread Starter
New Member
Thank you
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
|