H
Habib ur rehman
Guest
I want to apply the following conditions on textbox1 leave event:
1) if tab is pressed in textbox1 then the focus will be shifting to textbox2 so do nothing in textbox1 leave event.
2) if textbox2 is clicked then do nothing in textbox1 leave event.
3) else if textbox1 > textbox2 then display message "Textbox1 can't be greater" and focus on textbox1.
I tried this but it needs a function to be raised for it.
Dim look As Boolean
Private Sub Textbox1_Leave(sender As Object, e As EventArgs) Handles Textbox1.Leave
Dim Punch As KeyPressEventArgs = Textbox1.KeyPress
look = Nothing
If Textbox2.Focused Or Asc(Punch.KeyChar) = 9 Then
look = True
End If
Select Case look
Case False
If Textbox1.Text <> "" And Textbox2.Text <> "" And Textbox1.Text > Textbox2.Text Then
MsgBox("Textbox1 can't be greater")
Textbox1.Focus()
End If
End Select
End Sub
I tried keypress event with leave event but it seems that keypress mean nothing along with leave.
Thanks in advance.
Habib Ur Rehman
Continue reading...
1) if tab is pressed in textbox1 then the focus will be shifting to textbox2 so do nothing in textbox1 leave event.
2) if textbox2 is clicked then do nothing in textbox1 leave event.
3) else if textbox1 > textbox2 then display message "Textbox1 can't be greater" and focus on textbox1.
I tried this but it needs a function to be raised for it.
Dim look As Boolean
Private Sub Textbox1_Leave(sender As Object, e As EventArgs) Handles Textbox1.Leave
Dim Punch As KeyPressEventArgs = Textbox1.KeyPress
look = Nothing
If Textbox2.Focused Or Asc(Punch.KeyChar) = 9 Then
look = True
End If
Select Case look
Case False
If Textbox1.Text <> "" And Textbox2.Text <> "" And Textbox1.Text > Textbox2.Text Then
MsgBox("Textbox1 can't be greater")
Textbox1.Focus()
End If
End Select
End Sub
I tried keypress event with leave event but it seems that keypress mean nothing along with leave.
Thanks in advance.
Habib Ur Rehman
Continue reading...