I have a file of members in excel with al the details in 1 field like this:

fristname.lastname@emailadress.com,,,,,,membergroup

how can i split them in firstname, lastname, full email adress, membergroup so i can insert them in my table tblMembers?


Thanks

It could be done simply with VB.NET's Split method

Dim OneLine As String = "fristname.lastname@emailadress.com,,,,,,membergroup"
Dim SplittedLine() As String

' Split the whole string
SplittedLine = Strings.Split(OneLine, ",")
' Email address is now SplittedLine(0) and so on...

' Get first and last name
Dim Temp() As String

' First remove domain part
Temp = Strings.Split(SplittedLine(0), "@")

Dim Name() As String

' Finally, separate first and last name
Name = Strings.Split(Temp(0), ".")
' First name is in Name(0) and the last name is in Name(1)

Add proprietary error handling and "sanity" checks. The code blows if it encounters differently formatted data than expected ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.