LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default KeyPress: how to delete last character

I have a Userform that captures a date in a TextBox. I wish to allow
some user shortcuts whereby the user presses a keyboard character to
modify the date. For example, "+" increases the date by 1 day and "-"
reduces it by one day.

I have this working, but the keyed value is added to the TextBox.

For example, if the date is "1/1/07", pressing "+" will add a day like
this "2/1/07+".

I wish to remove the "+".

I tried deleting the last character in the KeyUp event, but this
removes the 7 but keeps the "+".

My code is:

Private Sub txtDate_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
With txtDate
Select Case KeyAscii
Case ASC_PLUS: .Value = DateValue(.Value) + 1
Case ASC_MINUS: .Value = .Value - 1
Case Else: Exit Sub
End Select

.Text = Format(.Text, "d/mm/yy")
End With
End Sub

Thanks in advance

Paul Martin
Melbourne, Australia

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete special character Kiannie Excel Discussion (Misc queries) 3 April 2nd 09 11:24 PM
Delete everything after a certain character [email protected] Excel Programming 4 November 21st 06 09:04 PM
Delete ascii character 127 CyndyG Excel Programming 2 May 4th 05 10:38 PM
Delete first character in ActiveCell Andy Excel Programming 8 November 17th 04 03:40 PM
Delete everything after a certain character? Chris Excel Programming 2 June 18th 04 09:59 PM


All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"