Subscript out of Range? What does that mean?
When I run this code:
VB Code:
Dim S As String
S = wb.Document.body.innerHTML
If TempPass Then
v = Split(S) ', vbNewLine)
For Each w In v
w = Split(w, "=")
'Debug.Print w(0), w(1)
If w(0) = "username" Then Form1.username.Text = w(1)
Next
Form18.Hide
Form1.Show
End If
on a webpage that looks like this
When in debugging mode, the W = "" for some reason and I get a subscript out of range...what does that mean?
Re: Subscript out of Range? What does that mean?
How do you declare w?
Also..
Code:
ThisMustBeAnArray = Split(ThisMustBeString, "=")
String declaration:
Dim s As Atring
Array Declaration (String Array):
Dim MyArray() As Atring
Re: Subscript out of Range? What does that mean?
Dim S As String, v As Variant, w As Variant
Re: Subscript out of Range? What does that mean?
Its because your setting the same array as your trying to split from.
VB Code:
[b]w[/b] = Split([b]w[/b], "=")
Re: Subscript out of Range? What does that mean?
Quote:
Originally Posted by takamine334
v = Split(S) ', vbNewLine)
Why did you comment the vbNewLine part?
Re: Subscript out of Range? What does that mean?
but it works until the last time when it makes w=""
Re: Subscript out of Range? What does that mean?
Re: Subscript out of Range? What does that mean?
Quote:
Originally Posted by jcis
Why did you comment the vbNewLine part?
because the code doesn't work with vbNewLine in...
Re: Subscript out of Range? What does that mean?
Quote:
Originally Posted by RobDog888
Its because your setting the same array as your trying to split from.
VB Code:
[b]w[/b] = Split([b]w[/b], "=")
that doesn't seem to be the problem. It splits it fine, it just seems to be putting a w="" after the last line for some reason
Re: Subscript out of Range? What does that mean?
Quote:
v = Split(S) ', vbNewLine)
For Each w In v
w = Split(w, "=")
'Debug.Print w(0), w(1)
If w(0) = "username" Then Form1.username.Text = w(1)
why are you using the same variable in all the places
Re: Subscript out of Range? What does that mean?
For Each w In v ?, usually used for collections.
You should use a For Next statement plus what is the value of "S" before you split because at the moment you are splitting at default which is a space and try to avoid variants
Dim S As String, v() As String, w() As String
casey.