Error in Function, System.Indexoutofrangeexception

Asked

Viewed 253 times

-1

I’m making a login system, When you click on the start button it starts the following code:

 Function Prencher2()

    Dim line() As String
    Dim emailsenha As String = List.Lines(0)
    line = Split(emailsenha, "|")
    Me.WebBrowser1.Document.GetElementById("liubw-user").SetAttribute("value", line(0))
    Me.WebBrowser1.Document.GetElementById("liubw-password").SetAttribute("value", line(1))
    Me.WebBrowser1.Document.GetElementById("liubw-submit").InvokeMember("click")
    WaitForPageLoad()
    Verificar()

End Function

OBS:List is the name of the textbox

In case it will put the email and password that is in the textbox and will click the login button. I am using the Function method because it is much faster to do what I want, put in part emailsenha As String = List.Lines(0)it gives the System error.Indexoutofrangeexception: 'the index was outside the matrix limits.'

What can I do to fix it? All my codes are correct because I have already tested manually.

  • 1

    Where is the declaration and assignment of List values?

  • List is the name of the textbox

  • Debugging what is the List value?

  • this is a code that I took that in the textbox you enter a list of email and password, in this textbox will be separated the email and password so: [email protected]|password, line(0) is the email and line(1) the password

1 answer

0


I took your code and tested location, and it works normally, the problem that in your test, you must be sending an empty value, so this giving the error, I think better put an if to check if what is coming from the textbox is empty, put before the line:

Dim emailsenha As String = List.Lines(0)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.