|
-
Feb 2nd, 2006, 12:38 AM
#1
Thread Starter
Addicted Member
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?
-
Feb 2nd, 2006, 12:45 AM
#2
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
-
Feb 2nd, 2006, 01:01 AM
#3
Thread Starter
Addicted Member
Re: Subscript out of Range? What does that mean?
Dim S As String, v As Variant, w As Variant
-
Feb 2nd, 2006, 01:03 AM
#4
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], "=")
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 2nd, 2006, 01:03 AM
#5
Re: Subscript out of Range? What does that mean?
 Originally Posted by takamine334
v = Split(S) ', vbNewLine)
Why did you comment the vbNewLine part?
-
Feb 2nd, 2006, 01:07 AM
#6
Thread Starter
Addicted Member
Re: Subscript out of Range? What does that mean?
but it works until the last time when it makes w=""
-
Feb 2nd, 2006, 01:08 AM
#7
Thread Starter
Addicted Member
Re: Subscript out of Range? What does that mean?
-
Feb 2nd, 2006, 01:13 AM
#8
Thread Starter
Addicted Member
Re: Subscript out of Range? What does that mean?
 Originally Posted by jcis
Why did you comment the vbNewLine part?
because the code doesn't work with vbNewLine in...
-
Feb 2nd, 2006, 01:16 AM
#9
Thread Starter
Addicted Member
Re: Subscript out of Range? What does that mean?
 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
-
Feb 2nd, 2006, 02:29 AM
#10
Re: Subscript out of Range? What does that mean?
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
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 2nd, 2006, 02:46 AM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|