Solved

Count length of string before unique character appears

Posted on 2011-02-11
3
220 Views
Last Modified: 2012-05-11
I'm looking for some simple vb code that will count the length of text in a string before the ":" symbol appears.

Regards
Antonio
0
Comment
Question by:cbsbutler
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 34870949
You can use the instr-function

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

http://www.aivosto.com/vbtips/instr.html
0
 
LVL 5

Accepted Solution

by:
skrga earned 500 total points
ID: 34870958
Dim strText As String
strText = "test:123"

Debug.Print Int(InStr(1, strText, ":", vbTextCompare)) - 1
0
 
LVL 8

Expert Comment

by:Den_HBR
ID: 34871018
VB6:
MsgBox (InStr("ThisTextIs16Long:AndHereSomeMoreText", ":")) - 1

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now