?
Solved

Parsing comma delimited string into textboxes

Posted on 2004-11-15
4
Medium Priority
?
330 Views
Last Modified: 2010-04-24
How would I parse a comma delimited string into multiple text boxes on my form ie:

FirstName, LastName, Birthdate,
Ralph, Malph, 12/25/2004
----------------------------------------
Dim WholeBirthdate as String
Dim Birthdate1 as String
Dim Birthdate2 as String
Dim Birthdate3 as String

txtFirstName.Text = From Beginning to First Comma
txtLastName.Text = From First Comma to Second Comma
WholeBirthdate = From Second Comma to the end
   Take WholeBirthdate and break it into three parts at each "/"
     Birthdate1 = the first number
     Birthdate2 = the second number
     Birthdate3 = the third number

    txtBirthdate1.Text = Birthdate1
    txtBirthdate2.Text  = Birthdate2
    txtBirthdate3.Text  = Birthdate3

How could I do that in vb.net
 
0
Comment
Question by:Matrix1000
  • 3
4 Comments
 
LVL 13

Accepted Solution

by:
imarshad earned 2000 total points
ID: 12587112
Dim myString As String = "FirstName, LastName, Birthdate,Ralph, Malph, 12/25/2004"

Dim myArray() As String = Split(myString,",")

txtFirstName.Text = myArray(0)
txtLastName.Text = myArray(1)
WholeBirthdate = myArray(2)

Dim myArray2() As String = Split(myString(3),"/")

    txtBirthdate1.Text = myArray2(0)
    txtBirthdate2.Text  = myArray2(1)
    txtBirthdate3.Text  = myArray2(2)
Imran




0
 
LVL 13

Expert Comment

by:imarshad
ID: 12587128
The line Dim myString As String = "FirstName, LastName, Birthdate,Ralph, Malph, 12/25/2004"
should have been

Dim myString As String = "Ralph, Malph, 12/25/2004"

Imran
0
 
LVL 13

Expert Comment

by:imarshad
ID: 12587235
Oops another typing error......

Dim myArray2() As String = Split(myString(3),"/")

should have been

Dim myArray2() As String = Split(myString(2),"/")

Note that in my sample I have used split function to split your string......Here is the complete declaration of Split function

Function Split(
   ByVal Expression As String,
   Optional ByVal Delimiter As String = " ",
   Optional ByVal Limit As Integer = -1,
   Optional ByVal Compare As CompareMethod = CompareMethod.Binary
) As String()


Imran
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question