Solved

Count length of string before unique character appears

Posted on 2011-02-11
3
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

687 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