I would like to know to remove spaces from start and end of a string without removing the middle space. Ex.

_ _String _ Sample _ _ = String sample

I have a code:

Text1.text = Replace(Text1, " ", "")

The code removes all the space in a text. Ex. _ _String_Sample_ _ = StringSample

I want the middle space to remain. Only the first and the last space will be removed.

Use the Trim function, as in -

Dim MyStrin As String

MyString = Trim$(Text1.Text)

Text1.Text = MyString

This will remove ONLY the first and last spaces

Thank you so much. . I just thought of it. . .I keep on using trim but I really don't know what its do. . .Funny me. . One question.

Is this code valid?

Trim$(StrConv(Text1.Text, vbProperCase))

I want to trim a Textbox which string is converted in Proper Case.

Yes it is. I have stuffed up a little with the code at

Trim&

Remove the & from trim. The Strconvert is perfect, as in -

Dim str As String

str = " nagatron "
Text1.Text = Trim(StrConv(str, vbProperCase))

This will return Nagatron, with no spaces.

Has this solved your problem Nagatron? If so, please mark this as solved, found at the bottom of this page, thanks.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.