[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Runtime Error 9 in VB App

Posted on 2004-11-12
Medium Priority
Last Modified: 2012-08-14
i have a VB6 program, which imports data from text files into a MS SQL DB.
i can run this program from inside vb6 on any computer without an error.
if i compile the exe and run it on Windows Server 2003, it  stops with "Runtime Error 9" end ends.
how can i find, which code is causing the error?
or is it an OS issue or something else?
Question by:WeHe
LVL 52

Accepted Solution

Carl Tawn earned 375 total points
ID: 12564041
Its quite possibly a Server 2003 related issue.  There are lots of changes/new features in 2003 that can effect the way some things work.  

Error number 9 is "Subscript out of range", so you need to start by looking at anywhere in your app that you use arrays (specifically looping through arrays)

Hope this helps.
LVL 76

Assisted Solution

GrahamSkan earned 375 total points
ID: 12564139
Subscript out of range is a common run-time error.

It could mean that you are now using external data to index an array, and that the number is not what was expected.

If you are certain that  you are always testing your data for sanity, then I suggest a trace log. There is a logging facility in VB, but it doesn't work in design mode, so I use a simple procedure. It starts a new one each day for easier management.

Sub WriteLog(Text As String)
    Dim f As Integer
    Dim strFileName As String
    strFileName = "abc" & Format$(Now, "MMy") & ".log"
    Text = Format$(Now, "HH:nn:ss") & " " & Text
    Debug.Print Text
    f = FreeFile
    Open App.Path & "\" & strFileName For Append As #f
        Print #f, Text
    Close #f
End Sub

As a start, try putting calls in at the top of each sub and function. That way you'll narrow it to down to a particular procedure.


Sub MyProc(Par1 as string)

Writelog "Procedure: MyProc. Parameter Par1=" & Par1

End Sub
LVL 10

Assisted Solution

fds_fatboy earned 375 total points
ID: 12564152
It could be that the app cannot find the text files on the server machine or a file is empty. My guess is that it loads arrays when processing the files and then in turn loops through the arrays processing them.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 48

Assisted Solution

Mikal613 earned 375 total points
ID: 12566098
please post code
LVL 11

Author Comment

ID: 12566726
When i have found the part, where the error is caused, i will post it.
atm i have to work on our wins for a while.
LVL 11

Author Comment

ID: 12583118
i don't know why, but now the app is running without any error.
thank you for your comments

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 6 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question