Hello-
What is the fastest way to determine if there are more than 1 "*" characters in a string?
Thanks - Pipe
Printable View
Hello-
What is the fastest way to determine if there are more than 1 "*" characters in a string?
Thanks - Pipe
If you are using VB 6.0, the quickest way is to use the Split command with the "*" as the delimiter like so
private Sub Command1_Click()
Dim strString
Dim strArray
strString = "**********"
strArray = Split(strString, "*")
MsgBox UBound(strArray) + 1
End Sub
John G
split function with "*" as delimiter should be quite fast (I think more than instr function in a loop for the len of the string exiting when not found anymore).
You will receive an array with ubound = number of "*" char -1.
Maybe you could do some fancy tricks with binary data and Copymemory Api, but these are not my best way of working...
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Beated in speed by you.
Sorry for my redundance, King.
;-)
Have a nice day, J.G.D.
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater