Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2006, 01:41 PM
Registered User
 
Join Date: Aug 2006
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)) = ""

 
Old August 18th, 2006, 04:31 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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

I am using VB6

 
Old August 18th, 2006, 05:29 PM
Friend of Wrox
 
Join Date: Nov 2004
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.
 
Old August 21st, 2006, 09:35 AM
Registered User
 
Join Date: Aug 2006
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







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





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