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?
Printable View
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?
use the Trim() function
VB Code:
yourstring = Trim$(yourstring)
casey.
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.
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 :) )
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)
Ah, I made my own code, but its slow :p
Thanks man, I'll test it later