AboutSyed Rizwan Muhammad Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.
Experience Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.
Question i put a condition on my on_leave property of my textbox. it worked out
well. but there's a slight problem, when it reached the condition that
it has to show a msgbox i have to close/click OK the msgbox twice and i
don't know why. here's the code of my textbox:
Private Sub TextBox12_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox12.Leave
If TextBox11.Text <> Nothing And TextBox12.Text = Nothing Then
TextBox13.Text = CDbl(TextBox11.Text) - 0
Exit Sub
ElseIf TextBox11.Text = Nothing And TextBox12.Text = Nothing Then
TextBox13.Text = 0
Exit Sub
ElseIf TextBox11.Text = Nothing And TextBox12.Text <> 0.0 Then
MsgBox("Total Amount must not be null.", MsgBoxStyle.Exclamation)
TextBox11.Focus()
Exit Sub
ElseIf TextBox11.Text <> Nothing And TextBox12.Text <> Nothing Then
TextBox13.Text = CDbl(TextBox11.Text) - CDbl(TextBox12.Text)
Exit Sub
End If
End Sub
Answer This might be due to the fact that after you click on OK for the first time the focus sets back to the same text box again. Please investigate that you don't any code which is executing TextBox12.Focus().
Also you can stop this by having a public flag variable. Which is set when the msgbox is displayed for the first time and next time the same event fires you simply ignore the event.