Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2006, 01:41 PM
Registered User
 
Join Date: Aug 2006
Location: omaha, NE, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koss77
Default Array, Subscript out of range.

Please help me debug this problem. The error was the subscript was out of range. here is the code:

Thank very much. The Idea seem to work but I have another problem. The value of -1 is not acceptable index for an array.
After I run the code I get this error : "subscript out of range"

Here is the part of the code that with the error:
 ReDim arrArrTestNewValue(UBound(arrArrayTest))

    For n = 0 To UBound(arrFields)
            For I = 0 To UBound(arrArrayTest)
              If arrArrayTest(I, 0) = arrFields(n) Then
                arrArrTestNewValue(I) = n

                Else
               arrArrTestNewValue(I) = -1

              End If
        Next I
    Next n



    Do While inFile.AtEndOfStream = False
        record = inFile.ReadLine
        arrFields = Split(record, Separator)

        Dim k As Integer

      If arrArrTestNewValue(k) = -1 Then
            arrFields(arrArrTestNewValue(k)) = ""

Reply With Quote
  #2 (permalink)  
Old August 18th, 2006, 04:31 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What VB flavor are you using? (Looks like v6; zatso?)
Reply With Quote
  #3 (permalink)  
Old August 18th, 2006, 04:37 PM
Registered User
 
Join Date: Aug 2006
Location: omaha, NE, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koss77
Default

I am using VB6

Reply With Quote
  #4 (permalink)  
Old August 18th, 2006, 05:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

VB 6 allows you to specify like:
Code:
    Dim MyArray(-8 To 30) As String ' Just for instance...
So you can use negative indices.
Reply With Quote
  #5 (permalink)  
Old August 21st, 2006, 09:35 AM
Registered User
 
Join Date: Aug 2006
Location: omaha, NE, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to koss77
Default

Thank you very much. This is very helpfull


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Subscript out of range" in acFormPivotChart jilly Access VBA 0 April 23rd, 2008 08:52 PM
Subscript out of range: '[number: 0]' jim_h Classic ASP Professional 0 February 24th, 2006 07:24 PM
Subscript out of range rfrancisco Classic ASP Components 1 February 13th, 2006 08:25 PM
Subscript out of range crmpicco Classic ASP Basics 4 March 22nd, 2005 06:55 PM
Problem of "Subscript out of range " liorlank Classic ASP Components 2 November 26th, 2003 10:45 AM



All times are GMT -4. The time now is 05:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.