|
-
Mar 24th, 2013, 11:15 AM
#1
Thread Starter
Member
How to split email string?
If I had an email-
[email protected]
How would I split it so the end result would be
firstnam.lastname?
Thanks in advance everyone
-
Mar 24th, 2013, 11:29 AM
#2
Hyperactive Member
Re: How to split email string?
Code:
Dim Email As String = "[email protected]"
Dim EmailStrSplit() As String = Email.Split(CChar("@"))
MessageBox.Show(EmailStrSplit(0))
-
Mar 24th, 2013, 11:34 AM
#3
Frenzied Member
Re: How to split email string?
There are lots of great examples around the internet, just google "Split string" in vb.net
Here is one great place to starthttp://www.homeandlearn.co.uk/net/nets7p7.html
Code:
'the text string you want to split up
Dim LineOfText As String = TextBox1.Text
'creates and array to store the differrent string parts
Dim aryTextFile() As String
'Set the character to split the string on
aryTextFile = LineOfText.Split("@")
'returns the first part of array
MsgBox(aryTextFile(0))
I hope this helps get you going
-
Mar 24th, 2013, 11:50 AM
#4
Re: How to split email string?
 Originally Posted by drawlings
[CODE]Dim EmailStrSplit() As String = Email.Split(CChar("@"))
FYI, VB does have char literals: "@"C so you don't actually need the CChar conversion.
Code:
Dim emailParts() As String = email.Split("@"C)
-
Mar 24th, 2013, 11:52 AM
#5
Thread Starter
Member
Re: How to split email string?
Thanks everyone All of these are working. I did search on google, but it was a little confusing. These examples are much better : D
-
Mar 24th, 2013, 11:56 AM
#6
Hyperactive Member
Re: How to split email string?
 Originally Posted by Joacim Andersson
FYI, VB does have char literals: "@"C so you don't actually need the CChar conversion.
Code:
Dim emailParts() As String = email.Split("@"C)
True, forgot about that.
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
|