1,105,546 Community Members

Removing space in start and end of a text

Member Avatar
nagatron
Junior Poster
109 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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

Member Avatar
nagatron
Junior Poster
109 posts since Aug 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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.

Member Avatar
AndreRet
Industrious Poster
4,492 posts since Jan 2008
Reputation Points: 362 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 24 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: