Hi All. Below you see the code to a very simple form which I created to duplicate a strange behavior on a much larger form and I am not sure what to make of it.
The form itself is the default form in VS 2013. It has 3 labels (vertical) and 3 textboxes next to them. If you use the textbox2.select() command in the textbox1_leave sub the program transfers to the textbox2_enter sub as expected. If you use the textbox3.select() command, however, the the program cycles twice in the textbox1_leave sub prior to leaving and then cycles twice in the textbox3_enter sub. I can only assume that this happens something to do with "tabindex" but what is really disturbing is the code is executed twice in the "from sub" and the "to" sub. This can't be normal. Any thoughts on this would be greatly appreciated. I have attached a jpeg image of the form itself.
Respectfully,
Ideprize
VB.NET:
Public Class Form1
Dim str1 As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MsgBox("form1 loaded")
Me.Show()
End Sub
Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click
End Sub
Private Sub TextBox1_Enter(sender As Object, e As EventArgs) Handles TextBox1.Enter
MsgBox("box1 in")
End Sub
Private Sub TextBox1_Leave(sender As Object, e As EventArgs) Handles TextBox1.Leave
MsgBox("box1 out")
str1 = TextBox1.Text
'TextBox2.Select()
TextBox3.Select()
End Sub
Private Sub TextBox2_Click(sender As Object, e As EventArgs) Handles TextBox2.Click
End Sub
Private Sub TextBox2_Enter(sender As Object, e As EventArgs) Handles TextBox2.Enter
MsgBox("box2 in")
MsgBox("str1 = " + str1)
End Sub
Private Sub TextBox2_Leave(sender As Object, e As EventArgs) Handles TextBox2.Leave
MsgBox("box2 out")
End Sub
Private Sub TextBox3_Click(sender As Object, e As EventArgs) Handles TextBox3.Click
End Sub
Private Sub TextBox3_Enter(sender As Object, e As EventArgs) Handles TextBox3.Enter
MsgBox("box3 in")
MsgBox("str1 = " + str1)
End Sub
Private Sub TextBox3_Leave(sender As Object, e As EventArgs) Handles TextBox3.Leave
MsgBox("box3 out")
End Sub
End Class
The form itself is the default form in VS 2013. It has 3 labels (vertical) and 3 textboxes next to them. If you use the textbox2.select() command in the textbox1_leave sub the program transfers to the textbox2_enter sub as expected. If you use the textbox3.select() command, however, the the program cycles twice in the textbox1_leave sub prior to leaving and then cycles twice in the textbox3_enter sub. I can only assume that this happens something to do with "tabindex" but what is really disturbing is the code is executed twice in the "from sub" and the "to" sub. This can't be normal. Any thoughts on this would be greatly appreciated. I have attached a jpeg image of the form itself.
Respectfully,
Ideprize
Attachments
Last edited by a moderator: