Dat kan natuurlijk ook niet op een KeyDown event omdat de benodigde informatie dan nog niet compleet is.
ok :-(
Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Dat kan natuurlijk ook niet op een KeyDown event omdat de benodigde informatie dan nog niet compleet is.
Dim Uur As String, Tarief As Single, x
With Worksheets("Declaratie")
Uur = .Range("A5")
Tarief = .Range("B6").Value
x = Split(Uur, ".")
MsgBox ("X(0) = " & x(0))
MsgBox ("X(1) = " & x(1))
Minuten = x(0) + x(1) / 60
' MsgBox ("Time = " & Minuten * Tarief)
End With
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
TextBox1 = Format(TextBox1, "00:00")
If TextBox1 = "" Or TextBox2 = "" Then GoTo Uit
With Worksheets("Declaratie")
.Range("A5").Value = TimeValue(TextBox2.Value) - TimeValue(TextBox1.Value)
End With
End If
Uit:
End Sub
Of
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
TextBox2 = Format(TextBox2, "00:00")
If TextBox1 = "" Or TextBox2 = "" Then GoTo Uit
With Worksheets("Declaratie")
.Range("A5") = TimeValue(TextBox2.Value) - TimeValue(TextBox1.Value)
.Range("C5") = .Range("A5")
End With
End If
Uit:
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
TextBox1 = Format(TextBox1, "00:00")
If TextBox1 = "" Or TextBox2 = "" Then GoTo Uit
With Worksheets("Declaratie")
[COLOR="#FF0000"].Range("A5").Value[/COLOR] = TimeValue(TextBox2.Value) - TimeValue(TextBox1.Value)
End With
End If
Uit:
End Sub
Of
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
TextBox2 = Format(TextBox2, "00:00")
If TextBox1 = "" Or TextBox2 = "" Then GoTo Uit
With Worksheets("Declaratie")
[COLOR="#FF0000"].Range("A5") =[/COLOR] TimeValue(TextBox2.Value) - TimeValue(TextBox1.Value)
.Range("C5") = .Range("A5")
End With
End If
Uit:
End Sub
Option Explicit
Private Sub StopKnop_Click()
Unload Me ' Verbergt Userform en maakt Var. leeg
Sheets("Declaratie").Range("A1").Activate ' Activeert Blad 1 Cel A1
End Sub
[COLOR="#FF0000"]Private Sub txtVan_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)[/COLOR]
KeyAscii = CheckTXT(txtVan, KeyAscii)
If txtVan = "" Or txtTot = "" Then GoTo Uit
Range("C4").Value = TimeValue(txtTot.Text) - TimeValue(txtVan.Text)
Uit:
End Sub
[COLOR="#FF0000"]Private Sub txtTot_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)[/COLOR]
KeyAscii = CheckTXT(txtTot, KeyAscii)
If txtTot = "" Or txtVan = "" Then GoTo Uit
Range("C4").Value = TimeValue(txtTot.Text) - TimeValue(txtVan.Text)
Uit:
End Sub
Function Zero2Nine(ByVal KeyAscii As Integer) As Boolean
Select Case KeyAscii
Case 48 To 58: Zero2Nine = True
End Select
End Function
Function CheckTXT(ByRef txtBox As MSForms.TextBox, ByVal KeyAscii As Integer) As Integer
If Len(txtBox.Text) = 5 Then CheckTXT = 0: Exit Function ' na 5 tekens exit
If Not Zero2Nine(KeyAscii) Then CheckTXT = 0: Exit Function ' geen geldig teken dan exit
If Len(txtBox.Text) = 2 Then txtBox.Text = txtBox.Text & ":" ' zet na 2e teken de ":" neer
CheckTXT = KeyAscii
End Function
Private Sub CommandButton1_Click()
Range("C4").Value = TimeValue(TextBox2.Text) - TimeValue(TextBox1.Text)
End Sub
Private Sub txtVan_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
Option Explicit
Private Sub StopKnop_Click()
Unload Me ' Verbergt Userform en maakt Var. leeg
Sheets("Declaratie").Range("A1").Activate ' Activeert Blad 1 Cel A1
End Sub
Private Sub UserForm_activate()
txtVan.SetFocus
End Sub
Private Sub txtVan_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(txtVan.Text) = 5 Then txtTot.SetFocus 'Exit Sub
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(",")
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub txtTot_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(txtTot.Text) = 5 Then Exit Sub
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(",")
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub txtVan_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
If txtVan = "" Or txtTot = "" Then GoTo Uit
With Worksheets("Declaratie")
.Range("C4").Value = TimeValue(txtTot.Value) - TimeValue(txtVan.Value)
End With
End If
Uit:
End Sub
Private Sub txtTot_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then ' Tab & Enter
If txtVan = "" Or txtTot = "" Then GoTo Uit
With Worksheets("Declaratie")
.Range("C4") = TimeValue(txtTot.Value) - TimeValue(txtVan.Value)
End With
End If
Uit:
End Sub
Private Sub txtVan_Change()
If Len(txtVan.Text) = 5 Then txtTot.SetFocus: Exit Sub ' max 5 tekens
If Len(txtVan.Text) = 2 Then txtVan.Text = txtVan.Text & ":" ' zet na 2e teken de ":" neer
End Sub
Private Sub txtTot_Change()
If Len(txtTot.Text) = 5 Then StopKnop.SetFocus: Exit Sub ' max 5 tekens
If Len(txtTot.Text) = 2 Then txtTot.Text = txtTot.Text & ":" ' zet na 2e teken de ":" neer
End Sub
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.