andycharger Posted January 23, 2004 Posted January 23, 2004 Hi. Im trying to trim spaces out of my User's names when I retrieve them from my SQL Server Database. Basically, I am pulling the first name and last name out and sticking them into a variable. The problem is that If im called "Joe Bloggs" It is retrieving "Joe " and "Bloggs " making me "Joe Bloggs " So I tried removing the spaces using Trim and Replace commands but neither seem to work. Can anyone help me with an alternative? Here is my code: strFName = oReader7("FirstName") Replace(strFName, " ", "") strLName = oReader7("LastName" Replace(strLName, " ", "") strName = strFName & " " & strLName Cheers Quote
andycharger Posted January 23, 2004 Author Posted January 23, 2004 Its putting spaces in but...... this forum seems to have ignored the spaces when I entered it!!! There are about 20 trailing spaces after both my first name and last name when I retrieve it! Quote
*Experts* mutant Posted January 23, 2004 *Experts* Posted January 23, 2004 The Replace method would work if you assinged the result back to your variable. But, you should not use the old VB6 functions. String object provides better alternatives. It also has a Replace method. Dim spaces As String = "SOME TEXT SOME TEXT SOME TEXT" spaces = spaces.Replace(" ", "") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.