View Single Post
  #3   Report Post  
Phil
 
Posts: n/a
Default

Excellent, thanks Bob.
Can i trouble you for another ?
It concerns an If statement.
In C8 i have
=IF(C2<0.208333333333333,0.208333333333333-C2,0)
which works fine but i also want to have to C7 decrease by 1 if the
statement is true and remain the same if it is false!
hope you understand me.

Thanks again


"Bob Phillips" wrote in message
...
Phil,

Here is one way, a bit kludgy but it works in full HH:MM mode

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim fColon As Boolean
Dim iPos As Long

iPos = InStr(1, TextBox1.Value, ":")
fColon = iPos 0
Select Case KeyAscii
Case 48 To 57: ' 0-9
Case 58: 'colon
If fColon Then
KeyAscii = 0 'colon already entered
End If
Case Else:
KeyAscii = 0
Exit Sub
End Select

If Len(TextBox1.Text) = 0 Or Len(TextBox1.Text) = 3 Then
If KeyAscii Asc("5") Then
KeyAscii = 0
Exit Sub
End If
ElseIf Len(TextBox1.Text) = 1 Then
'nothing to do
ElseIf Len(TextBox1.Text) = 2 Then
If KeyAscii Asc(":") Then
KeyAscii = 0
Exit Sub
End If
End If

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Phil" wrote in message
. uk...
How can i set a userform textbox properties so i can enter HH:MM.?

Thanks