Determine last character typed

T

Tim J La Fazia

Is there a way to determine the last character typed in a text box? I want
to run code in the on change event of a text box but not if the last letter
typed is a space.

TIA,
Tim
 
K

Ken Snell \(MVP\)

Read the Text property of the textbox (note: Text is a property that can be
read only when the textbox has the focus) and test the last character in the
Text property's result:

Private Sub TextBoxName_Change()
If Right(Me.TextBoxName.Text, 1) <> " " Then
' your code goes here
End If
End Sub
 
T

Tim J La Fazia

That works great,

Thanks!

Ken Snell (MVP) said:
Read the Text property of the textbox (note: Text is a property that can
be read only when the textbox has the focus) and test the last character
in the Text property's result:

Private Sub TextBoxName_Change()
If Right(Me.TextBoxName.Text, 1) <> " " Then
' your code goes here
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top