P
Paul Martin
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
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