Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

The software is stopping when button is clicked

$
0
0
I'm trying to write a software to get my lectures but there is a problem when I trying to check if the class I want is available. Here is the code I wrote for the checking function:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

    Dim bool As String = "0"
    While bool = "0"
        Dim x As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
        For Each curElement As HtmlElement In x
            Dim controlName As String = curElement.GetAttribute("name").ToString
            If controlName = "anadal_sube_degis[2615]" Then
                curElement.InvokeMember("click")
                Dim controlName2 As String = curElement.GetAttribute("name").ToString
                WebBrowser1.Refresh()
                If controlName2 = "sil[2615]" Then
                    bool = "1"
                    Label3.Text = "CONGRATZ!"
                End If
            Else
                Label3.Text = "Class is full."
                WebBrowser1.Refresh()
                Threading.Thread.Sleep(15000)
            End If
        Next
    End While


End Sub

Let me explain what I was thinking. My school's class picking page is full of tables and I cannot get the information by ID's or Name's. But I realized that every lecture has a unique number and that number wasn't random. So I figured out which number should I try for the lecture I want. As you can see "anadal_sube_degis[2615]" is the button I should click. But if the class is full, that button disappears. So I wanted to search whole web page to find this button and if it doesn't find it it searches again until it finds it. If it finds the button it should simply click on it, refresh the page and look up for the "delete" button (sil[2615]). If it finds the delete button it should exit the loop.

So here comes my problem: It freezes when I click Button3 in my application. I hope I could explain my problem well. So, any ideas?

Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>