View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Slim Slender[_2_] Slim Slender[_2_] is offline
external usenet poster
 
Posts: 39
Default KeyDown in TextBox to increment Number


This procedure for a textbox increments time by 15 minutes. I want to
change it so that
the content is a simple number in format "#0.00" and the KeyDown
increments the number by 0.25

Private Sub txtStartTime_KeyDown(ByVal KeyCode _
As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim sDate As String
Dim v As Integer
dte As Date

Select Case KeyCode
Case 37 ' Left
v = -1
Case 39 ' Right
v = 1
Case Else
v = 0
End Select
sDate = txtStartTime.Text

If IsDate(sDate) And v < 0 Then
dte = CDate(sDate)
dte = dte + v * TimeValue("00:15")
txtStartTime = Format(dte, "h:mm AM/PM")
End If
End Sub