Question

I have two buttons that refer to the same forms, one allows for information to be pasted in directly where as other is for putting information manually. When forms are completed they put the results into a text box.

What is happening is that if the input method is mixed, i,e some pasted or some manually inputted the buttons become out of sync, like button 1 may be at case 3 and button 2 will be case 5 so they may put results into wrong box or even replace an existing result.

based on the code below would there be a way to reference the state of each button, for example if button two is at case 3 then open form 5 (example).

Select Case _Step
            Case 0
                _Step = 1
                If String.IsNullOrEmpty(Me.TextBox6.Text) Then
                    popupform.Show()
                Else
                    Form3.Show()
                End If
                Exit Select

            Case 1
                _Step = 2
                If String.IsNullOrEmpty(Me.TextBox7.Text) Then
                    Form3.Show()
                Else
                    loadform3.Show()
                End If

                Exit Select

            Case 2
                _Step = 3
                If String.IsNullOrEmpty(Me.TextBox8.Text) Then
                    loadform3.Show()
                Else
                    loadform4.Show()
                End If
                Exit Select
Was it helpful?

Solution

public sub new()
    AddHandler Button1.Click, AdressOf firstclick
end sub

Private Sub firstclick(ByVal sender As System.Object, ByVal e As System.EventArgs) 
    If String.IsNullOrEmpty(Me.TextBox6.Text) Then
                popupform.Show()
     Else
                Form3.Show()
     End If
RemoveHandler Button1.Click, AddressOf firstclick
AddHandler Button1.Click, AdressOf secondclick    
End Sub

Private Sub secondclick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  If String.IsNullOrEmpty(Me.TextBox7.Text) Then
                Form3.Show()
  Else
                loadform3.Show()
  End If
End sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top