Posted on 2004-11-27
Last Modified: 2011-09-20
How do you use IndexOf to filter dash "-", comma "," and decimal point "." . MsgBox box would say wrong format.Thanks
Question by:Barako2
    LVL 11

    Accepted Solution

    Hi there,

    Something like:

    Dim myString As String
    myString = "Hello, good-day."

    If myString.IndexOf("-") <>-1 Then
           do something
    End If

    The Index of method returns a zero based index value indicating where in the string the character lies. For example, myString.IndexOf("-") would return the integer 12; the value -1 used above indicates that the hyphen does exist.

    Use AND to string together expressions if you are checking multiple characters.

    All the best

    LVL 11

    Expert Comment


    the value returned for the hyphen would be 11; 12-1.



    Author Comment

    Thank you very much for the Info.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 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

    13 Experts available now in Live!

    Get 1:1 Help Now