Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dash/Hyphen in textbox

Status
Not open for further replies.

tan8312

IS-IT--Management
Jul 1, 2004
3
0
0
US
I want to isolate the dashes that are entered in the textbox in a string. I want it to say:

(pseudocode)
if 4th character is not a dash ("-") then
msgbox("You must enter a dash as the fourth character.")
however, it is not responding correctly, the message keeps appearing even if I typed in a dash.

Please help!
Thanks in advance.


tan8312
System Support Coordinator
BIT Student
 
Use the IndexOf string function.

Example:
Code:
If TextBox1.Text.IndexOf("-") <> 3 Then
     '0 is the first character in the string
     MsgBox("you need a hyphen at character 4")
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top