We help IT Professionals succeed at work.

Trim a string - how?

Jens979
Jens979 asked
on
154 Views
Last Modified: 2010-05-02
Hello experts!!

I have a simple problem;
I have a string like so; "username@somedomain.com" -
and I want to remove the last 15 characters, the "@somedomain.com"
.
How can I do so??

Thank you!

/Jens*
Comment
Watch Question

Commented:
try something like this.
Private Sub Form_Load()
Dim a As String

a = "username@somedomain.com"
Text1.Text = Left$(a, 8)
End Sub
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Very nice!!
:)
Thank you!

/Jens*

Commented:
Try using this.  You might get better performance

Public Function TrimEmail(strEmail As String) As String
Dim llLocation As Long

llLocation = InStr(strEmail, "@") - 1
If llLocation > 0 Then
  TrimEmail = Left(strEmail, InStr(strEmail, "@") - 1)
Else
  TrimEmail = strEmail
End If
End Function
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.