|
-
Nov 6th, 2005, 03:14 AM
#1
Thread Starter
Hyperactive Member
remove spaces from the front and back?
how do i remove the spaces from this string: " Hello World "
i want to change that string to "Hello World"
so i just want to remove the space from the front and back, anyone know an easy way to do this?
-
Nov 6th, 2005, 03:19 AM
#2
Re: remove spaces from the front and back?
use the Trim() function
VB Code:
yourstring = Trim$(yourstring)
casey.
-
Nov 6th, 2005, 09:48 AM
#3
Re: remove spaces from the front and back?
If you need you can also use the LTrim$() and RTrim$() functions to remove whitespace from the left edge only and right edge only, respectively.
-
Nov 6th, 2005, 10:26 AM
#4
Addicted Member
Re: remove spaces from the front and back?
Text1.text = Trim$(Text1.text) - Will this work on a multilined textbox? Or whats the best way of doing that?
(not at home atm, so I can't test )
-
Nov 6th, 2005, 10:29 AM
#5
Re: remove spaces from the front and back?
It removes all whitespace from the left and right of a string.
If you want to apply it to all lines,
VB Code:
Dim lines() As String, i As Long
lines = Split(Text1.Text, vbNewLine)
For i = 0 To UBound(lines)
lines(i) = Trim$(lines(i))
Next i
Text1.Text = Join(lines, vbNewLine)
-
Nov 6th, 2005, 01:13 PM
#6
Addicted Member
Re: remove spaces from the front and back?
Ah, I made my own code, but its slow 
Thanks man, I'll test it later
Last edited by JensPeder; Nov 6th, 2005 at 01:20 PM.
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
|