this routine treats anything that is not an alpha-numeric character as ';special,'; including spaces, tabs, carriage returns, line feeds, etc. modify the code to explicitly reference anything you consider ';sepcial.';
Option Explicit
Dim msTitle As String
Private Sub Command1_Click()
Dim lsChar As String
Dim liChar As Integer
Dim li As Integer
Dim mBlnSpecial As Boolean
msTitle = Text1.Text
For li = 0 To Len(msTitle) - 1
lsChar = Mid(msTitle, li + 1, 1)
liChar = Asc(lsChar)
Select Case liChar
'--numbers
Case 48 To 57
'--lower case
Case 65 To 90
'--upper case
Case 97 To 122
Case Else
mBlnSpecial = True
Debug.Print (Asc(lsChar))
End Select
Next li
If mBlnSpecial = True Then
li = MsgBox(';There is at least one sepcial character.';, vbOKOnly, ';TEST';)
End If
End SubIn visual basic 6, how can you search a record containing special characters?
it's long cos i didn't clean up for extra returns. hadn't considered instr() at first - prolly wrote this when i was sleepy. glad it helped. i really don't understand what you're looking for - how is ';searching a record with apostrophe'; different from ';searching the occurrence of apostrophe?';
Report Abuse
You can ';escape'; the characters by putting a ' (a apostrophy) before like ('')
No comments:
Post a Comment