Re: Control Array KeyPress
let me format that...
VB Code:
Private Sub txtnewHr_KeyPress(Index As Integer, KeyAscii As Integer)
Dim TempVal As Long
TempVal = 0
If KeyAscii = 13 Then
If Index + 1 <= txtnewHr.Count Then
If T > Val(txtnewHr(Index).Text) Then
txtoldhr(Index).ForeColor = &H80000008
txtoldhr(Index).Text = Val(txtoldhr(Index).Text) + (T - Val(txtnewHr(Index).Text))
txtnewHr(Index + 1).SetFocus
ElseIf T <= Val(txtnewHr(Index).Text) Then
If Sgn(Val(txtoldhr(Index).Text)) = 1 Or Sgn(Val(txtoldhr(Index).Text)) = 0 Then
txtoldhr(Index).Text = txtoldhr(Index).Text - (Val(txtnewHr(Index).Text) - T)
txtoldhr(Index).ForeColor = &H80000008
If Index + 1 < txtnewHr.Count Then
txtnewHr(Index + 1).SetFocus
Else
cmdAdd.SetFocus
End If
End If
If Sgn(Val(txtoldhr(Index).Text)) = -1 Then
txtoldhr(Index).ForeColor = &HFF&
MsgBox "Exceeded Available Hours!", vbExclamation, "Alert!"
txtnewHr(Index).SetFocus
SendKeys "{Home}+{End}"
Exit Sub
End If
End If
End If
End If
End Sub