|
-
Oct 20th, 2010, 11:11 AM
#16
Thread Starter
Lively Member
Re: Seperating text in a textbox?
 Originally Posted by J-Deezy
With your properties problem, here's what your new class should look like:
Code:
Friend Class PeopleClass
Private xFirst as String = ""
Private xLast as String = ""
Private xCountry As String = ""
Public Property FirstName() As String
Get
Return xFirst
End Get
Set (ByVal value As String)
xFirst = value
End Set
End Property
Public Property LastName() As String
Get
Return xLast
End Get
Set (ByVal value As String)
xLast = value
End Set
End Property
Public Property Country() As String
Get
Return xCountry
End Get
Set (ByVal value As String)
xCountry = value
End Set
End Property
End Class
Now that you have that class, you can define a list(Of Class), like so:
Code:
Private ListPeople As New List(Of PeopleClass)
Then add to the class like this (probably not the best way)
Code:
Dim firstArr() As String = TextBox1.Text.Split(","c)
For i As Integer = 0 to firstArr.Count -1 Step 3
Dim nClass As New PeopleClass
With nClass
.FirstName = firstArr(i).Split(":"c)(1).Trim
.LastName = firstArr(i+1).Split(":"c)(1).Trim
.Country = firstArr(i+2).Split(":"c)(1).Trim
End With
ListPeople.Add(nClass)
Next
And you can now simply assign the list as a datasource to a listbox and display a specific property or whatever.
Thanks The class code worked, and makes sense, but with the listboxing code it seems to split up the name and put it in each listbox, and I don't know what happens to the rest of the info. Trying something else right now though 
btw what is the c for in (":"c)? i don't seem to find anything with it
Last edited by Raeki; Oct 20th, 2010 at 11:17 AM.
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
|