Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String parsing 1

Status
Not open for further replies.
Feb 10, 2007
4
US
I'm hoping this is something simple that I'm just overlooking but I can't figure it out. I'm trying to parse a string of text to determine how many leading spaces there are. For example, I have string " abc" and I want to be able to determine that there are three spaces at the start of this string. I have tried using the split function but can't figure out what delimiter to use to separate the string by each individual character, including the spaces. Also, in previewing my post, I noticed that it is only going to display one space in front of the "abc" example instead of three. So you will just have to pretend there are three blank spaces in front of "abc". Any help would be greatly appreciated. Thanks!
 
Code:
Public Function Leading(Txt As String)
Count = 1
Do Until Mid(Txt, Count, 1) <> " "
Count = Count + 1
Loop
Leading = Count - 1
End Function
 
Argh!

I knew there was a kill leading spaces function, but I couldn't find it.
 
Remove leading spaces.
msgbox lTrim(" ABC")

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top