Value from both WebBrowser and TextBox in VB

flyest

Doctor
Mar 3, 2013
94
13
Here's an If code for my new betting bot project.
Code:
If WebBrowser1.DocumentText.Contains("You lost 12 800 000") Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "4")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
I basically want to do the same thing in the first line as I do in the second (SetAttribute).
I want to know how I can make WebBrowser1 know if WebBrowser1.DocumentText.Contains both 'You lost' (HTML text) and text from TextBox1.

I didn't know how to explain this in a better way, but here's a demonstration in code on how I want it. Might help you.
Code:
WebBrowser1.DocumentText.Contains("You lost" And TextBox1.Text)
 

flyest

Doctor
Mar 3, 2013
94
13
Replace
Code:
If WebBrowser1.DocumentText.Contains("You lost 12 800 000") Then

with
Code:
If WebBrowser1.DocumentText.Contains("You lost") & WebBrowser1.DocumentText.Contains(TextBox1.Text) Then

should do the trick.
Thank you, kind sir! I tried a couple of combinations with And but it didn't work out for me. I just had to change the & in your code and now it works perfectly. :)
 
The reason I had to do it that way is because if the application only reads "You lost", it will jump to the maximum bet (TextBox1.Text * "4096").
Any idea how I make it know that if it loses the first time it will double the first bet (TextBox1.Text * "2") and so on?
Code:
 If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "2")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "4")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "8")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "16")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "32")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "64")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "128")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "256")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "512")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "1024")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "2048")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
        If WebBrowser1.DocumentText.Contains(TextBox3.Text) Then
            WebBrowser1.Document.GetElementById(TextBox6.Text).SetAttribute("value", TextBox4.Text * "4096")
            For Each el As HtmlElement In elc
                If el.GetAttribute("type").Equals("submit") Then
                    el.InvokeMember("Click")
                End If
            Next
        End If
 
Last edited:

Users who are viewing this thread

Top