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

x
?
Solved

Runtime Error 9 in VB App

Posted on 2004-11-12
6
Medium Priority
?
914 Views
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?
0
Comment
Question by:WeHe
6 Comments
 
LVL 52

Accepted Solution

by:
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.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
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.

e.g.

Sub MyProc(Par1 as string)
Dim....

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

...
End Sub
0
 
LVL 10

Assisted Solution

by:fds_fatboy
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.
0
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

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

Author Comment

by:WeHe
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.
0
 
LVL 11

Author Comment

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

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