Link to home
Start Free TrialLog in
Avatar of cbsbutler
cbsbutler

asked on

Count length of string before unique character appears

I'm looking for some simple vb code that will count the length of text in a string before the ":" symbol appears.

Regards
Antonio
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

You can use the instr-function

position = InStr("abc:def", ":") - 1

http://www.aivosto.com/vbtips/instr.html
ASKER CERTIFIED SOLUTION
Avatar of skrga
skrga
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Den_HBR
Den_HBR

VB6:
MsgBox (InStr("ThisTextIs16Long:AndHereSomeMoreText", ":")) - 1

VB.NET:
MsgBox("ThisTextIs16Long:AndHereSomeMoreText".IndexOf(":"))