• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

IndexOf

How do you use IndexOf to filter dash "-", comma "," and decimal point "." . MsgBox box would say wrong format.Thanks
0
Barako2
Asked:
Barako2
  • 2
1 Solution
 
Babycorn-StarfishCommented:
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

JW
0
 
Babycorn-StarfishCommented:
Oops,

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

Lol


JW
0
 
Barako2Author Commented:
Thank you very much for the Info.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now