Hello guys and Good day!

I just want a little help on how to get the total number of space from the left until the word starts and display the total space in msgbox..

Example:

combo1.AddItem = "                        Bank       "

In this example the total number of space from the left is 30.

Thank you for your reply..Thank you.!

God bless!

Look up the mid function and put it in a loop.

thank you for the reply...but what is the function to detect the space when i used the mid function?

Look up the mid function and put it in a loop.

thank you for the reply...but what is the function to detect the space when i used the mid function?

commented: Don't post twice. Edit the original post. -3

(length of the string including space ) - (lenth of the string after LTRIM) = number of spaces in the start of the string.

Len("Visual Basic") - Len(ltrim("Visual Basic"))

Look up the mid function and put it in a loop.

thank you for the reply...but what is the function to detect the space when i used the mid function?

If you look up the function, I'm sure you can figure it out.

thank you guys..

this formula works without looping...

dim total space as integer

totalspace = Len("Visual Basic") - Len(ltrim("Visual Basic"))

msgbox totalspace

One last clarification...Can i additem on a combo box that will start at position 11 or the total space value without looping?

This means that when i add new item, it will automatically add 11 space or base upon the totalspace variable value from the left..

Please add the code above if its possible..

thank you once again to all of you guys..

God bless

final solution..

dim total space as integer
 
totalspace = Len("Visual Basic") - Len(ltrim("Visual Basic"))
 
msgbox totalspace

now to add item depending on totalspace var.here it is..

combo1.additem Space$(totalspace) & "Hello"

thank you guys

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.