Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 May 20th, 2004, 01:45 AM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default RUN-TIME ERROR

I have sent out many postings in the last couple of weeks. I have found the answers to those questions and now need help on this posting rather than the others. This posting may sound like one of my last postings but it is different in many ways. I also want to thank all those that have tried to help in my last postings.

THANK YOU

My question deals with another RUN-TIME ERROR.
I have created a program that works fine when arguments are being passed to the .VBP when the argument is null or empty the .VBP will send out a message that tells the user to see the adminastrator. All these arguments are passing fine, but when I take the .VBP and try to compile the project it will run fine when passed arguments and I will then recieve a RUN-TIME ERROR '9' SUBSCRIPT OUT OF RANGE message when you click on the .EXE file. Is what I want the program to do when the .EXE is pressed is show a message as such [THIS IS NOT A STANDALONE PROGRAM.]

here is the code I am using if you need more help I will get it to you.

THANK YOU

Code:
Private Sub Form_Activate()

Dim strValuesFromCommandLine() As String
Dim CmdLine As String
Dim RAFFLEID As String
Dim PASSWORD As String
Dim FirstTicketNo As String
Dim LastTicketNo As String
Dim RAFFLEID1a As String

    Form1.WindowState = 0

 strValuesFromCommandLine() = Split(Command$, ", ")
 CmdLine = strValuesFromCommandLine(0)
 RAFFLEID = strValuesFromCommandLine(1)
 PASSWORD = strValuesFromCommandLine(2)
 FirstTicketNo = strValuesFromCommandLine(3)
 LastTicketNo = strValuesFromCommandLine(4)



If PASSWORD = "1TheSecretPassword" Then
    'Enter RaffielD.
    If RAFFLEID > " " Then
        DataPath = Mid(App.Path, 1, 29) & "rmdesktop\whdata.mdb"
        DataPath1a = Right(DataPath, 11)
        Data1.DatabaseName = DataPath
        Data1.Connect = ";PWD=TheSecretPassword"
        RAFFLEID1a = RAFFLEID
        number1 = "select RaffleId, Prize1, NumberofTicketsAvailable,
shortdescription, longdescription, raffleenddate, Ticketcost, " & _
        "Timeplace, CharityName from raffles Inner Join charity on
Raffles.CharityId = charity.CharityId Where RaffleID like '" & RAFFLEID1a
& "*'"
        Data1.RecordSource = number1
        Data1.Refresh
        Data1.Recordset.FindFirst "RaffleID = '" & RAFFLEID1a & "'"
        Frame3.Visible = False
        Frame1.Visible = True
        Form1.Height = 4920
        If Data1.Recordset.NoMatch Then
            Form1.Height = 2055
            Frame3.Visible = True
            Label4.Visible = True
            Label4.Caption = "There was no RaffleID matching the data in
the Database."
        End If
    ElseIf RAFFLEID = " " Then
        Frame3.Visible = True
        Label4.Visible = True
        Label4.Caption = "No RaffleID was entered."
    End If
ElseIf PASSWORD <> " TheSecretPassword" Then
    Label4.Visible = True
    Label4.Caption = "Enter the correct PASSWORD or see the administrator."
End If

If Option2 = False Then
    txtValue.Enabled = False
    Text2.Enabled = False
    cmdPrint_Singles.Enabled = False
End If

If Option1 = False Then
    cmdPrint_All.Enabled = False
End If

End Sub
 
Old May 20th, 2004, 12:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear Stephen,
this is absolutely trivial :)
out of range: look into you code and you can see only one array. if no arguments are passed (or less than 5) your code will always bomb because you access the strValuesFromCommandLine 0 to 5
To fix this... well there are meny ways, pick your favourite
Marco
 
Old May 21st, 2004, 02:01 AM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

one thing i had noticed was when i used the debug feature i placed it over CmdLine varible and it shows that [TBLITE.EXE CmdLine] was passed where as the other variables passed ok i am wondering if this could be my run time error 9 problem if so what can i do to split this. i tried using a comma to split it but this moves everything one spot in the command line area of make.exe area it is setup as such: TBLITE.EXE CmdLine, RAFFLEID, PASSWORD, FirstTicketNo, LastTicketNo

Dim strValuesFromCommandLine() As String
Dim CmdLine As String
Dim RAFFLEID As String
Dim PASSWORD As String
Dim FirstTicketNo As String
Dim LastTicketNo As String
Dim RAFFLEID1a As String

    Form1.WindowState = 0

 strValuesFromCommandLine() = Split(Command$, ", ")
 CmdLine = strValuesFromCommandLine(0)
 RAFFLEID = strValuesFromCommandLine(1)
 PASSWORD = strValuesFromCommandLine(2)
 FirstTicketNo = strValuesFromCommandLine(3)
 LastTicketNo = strValuesFromCommandLine(4)

thank you







Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
Run-time error '2450' bmurrin Access VBA 6 May 31st, 2006 07:11 AM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM





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