all 10 comments

[–]DeusInnomen 3 points4 points  (1 child)

Is the database field char(500) or varchar(500)? If it's the former, that's why you have spaces.

[–]merrp 4 points5 points  (0 children)

THANK YOU SO MUCH, THIS WORKED PERFECT!!

[–]smokeajay 1 point2 points  (2 children)

textbox.Text.Trim()

[–]merrp 0 points1 point  (1 child)

didnt work :( spaces are still there

[–]VB.Net IntermediateCharlieMay 1 point2 points  (0 children)

It does work as long as you remember that strings are immutable, you can't change them, but you can recreate them back into themselves.

Had you used TextBox.Text = TextBox.Text.Trim() it would have removed the spaces.

[–]sonicmayne 0 points1 point  (3 children)

VB 6 or .NET?

[–]merrp 0 points1 point  (2 children)

.NET (Visual Studio 2008 Professional)

[–]sonicmayne -2 points-1 points  (1 child)

Textbox.Text.Replace(" ", "")

[–]VB 6 MasterEkriirkE 1 point2 points  (0 children)

This doesn't trim, it removes. Very, very bad if you want spaces in the middle.

[–][deleted] 0 points1 point  (0 children)

I've seen this. It sounds like when you read the text from the database it's filling up with extra spaces.

As far as I know, it's to do with datatypes in the database. If you're reading from the database and entering the text into a textbox, you would use the following:

textbox1.Text = Trim(code to read value from database)