简体   繁体   中英

VB 2010, ignoring occupied Textboxes

I have a button that handles multiple clicks and imports information into associated text boxes. I am trying to make it so that if a text box is occupied then it will insert the information into the next available box. If the text box is occupied then it should open form 3 and if not then it will open poppupform.

The way I have attempted this as seen below is to try and skip the box if the value is more or less than zero. For some reason it does not identify this. Apologies, I am fairly new to this and happy to explain further if needs be.

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Select Case _Step
            Case 0
                _Step = 1
                If Val(Form1.TextBox6.Text) = 0 Then
                    Dim resistivity As Double
                    resistivity = Val(Me.results.Text)
                    popupform.TextBox4.Text = Convert.ToString(resistivity)
                    popupform.Show()
                    If Val(Form1.TextBox6.Text) <= 0 Or Val(Form1.TextBox6.Text) >= 0 Then
                        Dim resistivity2 As Double
                        resistivity2 = Val(Me.results.Text)
                        Form3.TextBox4.Text = Convert.ToString(resistivity2)
                        Form3.Show()
                        popupform.Close()
                        Exit Select
                    End If
                End If
                Exit Select

@user2375267

Replace the first "IF" statement to:

If( Not String.IsNullOrEmpty( Form1.TextBox6.Text ) )

Then move the content of the inner "IF" to a new "Else" statement. So it will look like:

If( Not String.IsNullOrEmpty( Form1.TextBox6.Text ) ) Then

   ...    
   popupform.Show()
   ...

Else

  ...
  Form3.Show()
  ...

End If

This should check if TextBox6.Text has a value. If it does, then it will show one form. If not, then it will display another.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM