Detecting a Character

  • Thread starter Thread starter Peter Marshall
  • Start date Start date
P

Peter Marshall

I'm looking for a simple way to check that the text entered into a text box
contains a slash at the end. I'm assuming VBA that executes On_Exit.
 
On Mon, 8 Mar 2010 08:30:18 -0500, "Peter Marshall"

if right$(Me.myTextBox,1) = "/" then
'yes it does
else
'no it doesn't
end if

-Tom.
Microsoft Access MVP
 
Private Sub Text1_Exit(Cancel As Integer)
If Not Right(Me.Text1, 1) = "/" Then
Cancel = True
MsgBox "No '/'", vbExclamation
End If
End Sub
 
hi Peter,

I'm looking for a simple way to check that the text entered into a text box
contains a slash at the end. I'm assuming VBA that executes On_Exit.
You may use a input mask or use this in your event:

Const COLOR_LIGHTBLUE As Long = 15713933
Const COLOR_WHITE As Long = 16777215

Dim length As Long

length = Len(Trim(Nz(txtYourControl.Value, "")))
If (length > 0) And _
(Mid(txtYourControl.Value, length, 1) <> "-") Then
txtYourControl.BackColor = COLOR_LIGHTBLUE
Else
txtYourControl.BackColor = COLOR_WHITE
End If

btw, I would use the On Change event.


mfG
--> stefan <--
 
hi Stefan,

Const COLOR_LIGHTBLUE As Long = 15713933
Const COLOR_WHITE As Long = 16777215

Dim length As Long

length = Len(Trim(Nz(txtYourControl.Value, "")))
If (length > 0) And _
(Mid(txtYourControl.Value, length, 1) <> "-") Then
txtYourControl.BackColor = COLOR_LIGHTBLUE
Else
txtYourControl.BackColor = COLOR_WHITE
End If

btw, I would use the On Change event.
In this case you must use txtYourControl.Text instead of
txtYourControl.Value,


mfG
--> stefan <--
 
Back
Top