dcsimg
Results 1 to 20 of 20

Thread: VB6 Invalid Procedure Call or Argument

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    VB6 Invalid Procedure Call or Argument

    Working with a pretty old codebase and have hit a wall during some integration testing. The code actually hasn't changed in a year or more but this error just started popping up out of nowhere.

    Here is the code that is throwing the error message.

    Code:
    Private Sub cmdViewReport_Click()
    
    On Error GoTo ErrorHandler
    
        ' call the UC for the report
        Dim mTest As Boolean
        mTest = objUC.GetImportTotalReport
    
        If mTest = True Then
            ' update a record to the import control table step 6
            ' to recover move the rmPriorImport table data to the
    RMCurrentImport table
            ' and truncate the rmLoadImport and RmImportTran
            objUC.ImportStepCd = "6"
            objUC.RegisterStep mTest
            If mTest = False Then GoTo ErrorHandler
    
            cmdAcceptImport.Enabled = True
            cmdAcceptImport.SetFocus
            cmdRejectImport.Enabled = True
        End If
    
    Exit Sub
    ErrorHandler:
        HandleError "UI.cmdView_Click", True
    End Sub
    This hits mTest = objUC.GetImportTotalReport and sends you into this part of the code, which is where the error is thrown.

    Code:
    Public Function GetImportTotalReport() As Boolean
    
        Dim Boot As RlasBoot.BootStrap
        Dim sCookie As String
        Dim msFileNamesTx As String
        Dim msReportPath As String
    
        GetImportTotalReport = False
        Set Boot = New RlasBoot.BootStrap
        msReportPath = Boot.ReportPath
    
        If Right(msReportPath, 1) <> "\" Then
            msReportPath = msReportPath & "\"
        End If
    
        If Trim(msPreviousFileName) <> "" Then
            msFileNamesTx = Trim(msCurrentFileName) & "  (Size: " &
    Format(CStr(mlCurrentFileSize), "###,###,###,###") & ")  " & "Date: " &
    mdCurrentFileDt & _
                        Trim(msPreviousFileName) & "(Size: " &
    Format(CStr(mlPreviousFileSize), "###,###,###,###") & ")" & "Date: " &
    mdPreviousFileDt
        Else
            msFileNamesTx = Trim(msCurrentFileName) & "  (Size: " &
    CStr(mlCurrentFileSize) & ")  " & "Date: " & mdCurrentFileDt
        End If
    
        ' pass the file names imported for the report variable name is
    msFileNamesTx
        If Dir(msReportPath & "RMStanfinOblig.exe") <> "" Then
            sCookie = "STEREO SPEAKER"
            Shell """" & msReportPath & "RMStanfinOblig.exe""" & " " & _
                sCookie & "," & msServer & "," & msDatabase & _
                "," & msUserOrgId & "," & msFileNamesTx, vbNormalFocus
            GetImportTotalReport = True
        Else
            Err.Raise 500, "RMStanfins_UC.GetImportTotalReport", "The file
    associated with this report could not be found."
        End If
    End Function
    From my research and working on this 12 hours today which has halted all testing. I can only assume that the "vbNormalFocus" is somehow now causing a problem. After ruling out any type of database issue. If anyone else has any other ideas, I would very much like to hear them.

    Appreciate all your help.

    Abrham Smith

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: VB6 Invalid Procedure Call or Argument

    You have way to many parameters in there for the shell function. The shell function accepts up to 2 parameters. The path of the exe is required and then there is the optional window style parameter. Maybe you were thinking of ShellExecute instead.

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,842

    Re: VB6 Invalid Procedure Call or Argument

    Abrham,

    First, welcome to VBforums.

    From what you've provided, it appears that the "objUC" variable is declared (DIMmed) as some module level or global level class or object variable. Please verify this.

    I'm further assuming that the GetImportTotalReport procedure was cut out of a class (CLS) module. Please verify this as well.

    If those things are correct, you need to set a break-point at the top of your GetImportTotalReport and then trace through it, watching for what's causing the error.

    Also, you might want to comment out your error trapping line "On Error GoTo ErrorHandler" so that the error just "happens".

    You need to figure out the exact line causing the error and also tell us what the error code is.

    Once that's done, you're either going to figure it out on your own, or we'll be able to better help you figure it out.

    Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 Invalid Procedure Call or Argument

    I second elroy's motion.
    Your error handler trashes the original error code and message, so it's basically worthless. just comment it out, and come back with the actual error.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by MarkT View Post
    You have way to many parameters in there for the shell function. The shell function accepts up to 2 parameters. The path of the exe is required and then there is the optional window style parameter. Maybe you were thinking of ShellExecute instead.
    The Shell Function is only using 1 parameter and that is calling the Exe. The other parameters are for the EXE itself.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by Elroy View Post
    Abrham,

    First, welcome to VBforums.

    From what you've provided, it appears that the "objUC" variable is declared (DIMmed) as some module level or global level class or object variable. Please verify this.

    I'm further assuming that the GetImportTotalReport procedure was cut out of a class (CLS) module. Please verify this as well.

    If those things are correct, you need to set a break-point at the top of your GetImportTotalReport and then trace through it, watching for what's causing the error.

    Also, you might want to comment out your error trapping line "On Error GoTo ErrorHandler" so that the error just "happens".

    You need to figure out the exact line causing the error and also tell us what the error code is.

    Once that's done, you're either going to figure it out on your own, or we'll be able to better help you figure it out.

    Regards,
    Elroy
    You're correct in your first two assumptions.

    I wish I was able to set breakpoints, but this is not development, this is production code that I do not have a development environment for. Sorry about the constraints of my situation but I wish they were different, trust me.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,999

    Re: VB6 Invalid Procedure Call or Argument

    I also agree with the advice to comment out the error handler.
    Another option would be to add an error handler in the routine that you believe is causing the issue, also add line numbers to it and then display the line number along with the error code and error message,

  8. #8
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by Abrham View Post
    The Shell Function is only using 1 parameter and that is calling the Exe. The other parameters are for the EXE itself.
    Every comma you have in the shell command is being interpreted as parameter separator. So in your case it looks like you are passing the exe with an sCookie (command) parameter. Then the shell function is seeing 5 additional parameters. msServer, msDatabase, msUserOrgId, msFileNamesTx, vbNormalFocus
    Instead of separating those command parameters with commas try separating them with spaces. Maybe something like this.
    Code:
        strExePath = msReportPath & "RMStanfinOblig.exe"
    
        Shell Chr(34) & strExePath & Chr(34) & " " & _
                Chr(34) & sCookie & Chr(34) & " " & _
                Chr(34) & msServer & Chr(34) & " " & _
                Chr(34) & msDatabase & Chr(34) & " " & _
                msUserOrgId & " " & _
                Chr(34) & msFileNamesTx & Chr(34), vbNormalFocus

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,999

    Re: VB6 Invalid Procedure Call or Argument

    At first I thought the commas were a problem as well but they are in quotes so I do not think that is the issue

  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by MarkT View Post
    Every comma you have in the shell command is being interpreted as parameter separator. So in your case it looks like you are passing the exe with an sCookie (command) parameter. Then the shell function is seeing 5 additional parameters. msServer, msDatabase, msUserOrgId, msFileNamesTx, vbNormalFocus
    Instead of separating those command parameters with commas try separating them with spaces. Maybe something like this.
    Code:
        strExePath = msReportPath & "RMStanfinOblig.exe"
    
        Shell Chr(34) & strExePath & Chr(34) & " " & _
                Chr(34) & sCookie & Chr(34) & " " & _
                Chr(34) & msServer & Chr(34) & " " & _
                Chr(34) & msDatabase & Chr(34) & " " & _
                msUserOrgId & " " & _
                Chr(34) & msFileNamesTx & Chr(34), vbNormalFocus
    The shell command runs fine in Powershell. I mentioned earlier in another reply, this is production code, I am unable to change it. This error was not happening previously and suddenly started coming up without code changes. Unfortunately I don't have a development environment where I can just set breakpoints and see what is happening. :/

  11. #11
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by DataMiser View Post
    At first I thought the commas were a problem as well but they are in quotes so I do not think that is the issue
    If you run this you see the difference in what is being sent to the shell command.
    Code:
    Private Sub Command1_Click()
    Dim msReportPath As String
    Dim sCookie As String
    Dim msServer As String
    Dim msDatabase As String
    Dim msUserOrgId As Integer
    Dim msFileNamesTx As String
    Dim strExePath As String
    
    
        msReportPath = "c:\"
        sCookie = "STEREO SPEAKER"
        msServer = "ServerName"
        msDatabase = "DatabaseName"
        msUserOrgId = 123
        msFileNamesTx = "FileName"
        
        strExePath = msReportPath & "RMStanfinOblig.exe"
        
        Debug.Print "Without commas"
        Debug.Print Chr(34) & strExePath & Chr(34) & Space(1) & _
                Chr(34) & sCookie & Chr(34) & Space(1) & _
                Chr(34) & msServer & Chr(34) & Space(1) & _
                Chr(34) & msDatabase & Chr(34) & Space(1) & _
                msUserOrgId & Space(1) & _
                Chr(34) & msFileNamesTx & Chr(34), vbNormalFocus
                
         Debug.Print
         Debug.Print "With commas"
         Debug.Print """" & msReportPath & "RMStanfinOblig.exe""" & " " & _
                sCookie & "," & msServer & "," & msDatabase & _
                "," & msUserOrgId & "," & msFileNamesTx, vbNormalFocus
                
    End Sub
    The outputs are...

    Without commas
    "c:\RMStanfinOblig.exe" "STEREO SPEAKER" "ServerName" "DatabaseName" 123 "FileName" 1

    With commas
    "c:\RMStanfinOblig.exe" STEREO SPEAKER,ServerName,DatabaseName,123,FileName 1

  12. #12
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: VB6 Invalid Procedure Call or Argument

    you can't change the code, you can't debug, and you don't have a proper error handler.
    this seems like a losing battle.

  13. #13

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by DEXWERX View Post
    you can't change the code, you can't debug, and you don't have a proper error handler.
    this seems like a losing battle.
    I know, it's a terrible situation. Was worth a shot to post up and see what other people thought of the situation. I really appreciate everyone's responses.

  14. #14
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,999

    Re: VB6 Invalid Procedure Call or Argument

    Well if it is a case of the code not running and not having been changed in anyway and you can not make any changes to it then the only thing I can think of is that perhaps some support file is missing or changed.

    The outputs are...

    Without commas
    "c:\RMStanfinOblig.exe" "STEREO SPEAKER" "ServerName" "DatabaseName" 123 "FileName" 1

    With commas
    "c:\RMStanfinOblig.exe" STEREO SPEAKER,ServerName,DatabaseName,123,FileName 1
    But my point was that on the line that has Shell() the only comma that is not enclosed in quotes is the last one so what is actually being passed to the shell function is

    Code:
    Shell(ProgramPathNameAndArguments,vbnormalfocus)
    The fact that the string being built on the fly contains commas should not confuse the ShellFunction since they are all within the string. The program being called on the other hand would of course have to parse the comma delimited list of arguments but so long as it is coded to do so then it should not be an issue.

    Removing the commas would surely break it if it is coded to expect them

  15. #15

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    You are most certainly correct DataMiser. The EXE is coded to expect those arguments and if you don't provide them it will throw a subquery error.

  16. #16
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,842

    Re: VB6 Invalid Procedure Call or Argument

    Ok, weighing back in. First, I looked hard at that "Shell" statement, and I don't see anything wrong with it. However, I also know absolutely nothing about the RMStanfinOblig.exe program. I have no idea what command line arguments it can process and/or how they're delimited. But, if that has been working up to now, and this RMStanfinOblig.exe hasn't been recently updated, I don't see how that's the problem. Also, the "Shell" statement (from a VB6 perspective) does look like it's correctly structured. Therefore, it's not going to cause an error in VB6. It may cause the RMStanfinOblig.exe program to fail, but that won't be noticed by VB6.


    Next, so you do NOT have the VB6 Integrated Development Environment (IDE) installed anywhere? If that's the case, how do you even know that you've identified the correct procedure/area that's causing the error? In my humble opinion, you've GOT to get a copy of the VB6 IDE installed on a computer, and then execute this code from within the IDE to have any hope what-so-ever of figuring this out. You can get copies on eBay for a couple hundred. In your case, it might even be okay to go with a VB6 IDE "Learning Edition". The major downside to the Learning Edition is that you can't compile your program into an executable (EXE). But that's probably not necessary to at least identify/find the error you're having.

    If you do explore the eBay option, ideally you'd want to get a copy of the VB6 IDE Professional. The following is a link to a possibility. I just searched eBay for you:
    http://www.ebay.com/itm/Microsoft-Vi...UAAMXQCtlRWFk4

    Also, don't get an "Upgrade" version unless you have a copy of VB5 or VB4, etc lying around.

    Also, if you do get the VB6 IDE, you'll want to install the VB6 Service Pack 6 after it's installed and before you do much else. It's free, and here's a link to that:
    http://motionlabresources.org/VB60SP...v2-x86-ENU.msi

    Good Luck,
    Elroy
    Last edited by Elroy; Jul 22nd, 2016 at 09:09 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  17. #17

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    7

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by Elroy View Post
    Ok, weighing back in. First, I looked hard at that "Shell" statement, and I don't see anything wrong with it. However, I also know absolutely nothing about the RMStanfinOblig.exe program. I have no idea what command line arguments it can process and/or how they're delimited. But, if that has been working up to now, and this RMStanfinOblig.exe hasn't been recently updated, I don't see how that's the problem. Also, the "Shell" statement (from a VB6 perspective) does look like it's correctly structured. Therefore, it's not going to cause an error in VB6. It may cause the RMStanfinOblig.exe program to fail, but that won't be noticed by VB6.


    Next, so you do NOT have the VB6 Integrated Development Environment (IDE) installed anywhere? If that's the case, how do you even know that you've identified the correct procedure/area that's causing the error? In my humble opinion, you've GOT to get a copy of the VB6 IDE installed on a computer, and then execute this code from within the IDE to have any hope what-so-ever of figuring this out. You can get copies on eBay for a couple hundred. In your case, it might even be okay to go with a VB6 IDE "Learning Edition". The major downside to the Learning Edition is that you can't compile your program into an executable (EXE). But that's probably not necessary to at least identify/find the error you're having.

    If you do explore the eBay option, ideally you'd want to get a copy of the VB6 IDE Professional. The following is a link to a possibility. I just searched eBay for you:
    http://www.ebay.com/itm/Microsoft-Vi...UAAMXQCtlRWFk4

    Also, don't get an "Upgrade" version unless you have a copy of VB5 or VB4, etc lying around.

    Also, if you do get the VB6 IDE, you'll want to install the VB6 Service Pack 6 after it's installed and before you do much else. It's free, and here's a link to that:
    http://motionlabresources.org/VB60SP...v2-x86-ENU.msi

    Good Luck,
    Elroy
    Without getting into too much detail, I have an Enterprise Version of VB6. However, the environment I am provided does not allow me to run this code on their networks. It's a mess.

  18. #18
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: VB6 Invalid Procedure Call or Argument

    Quote Originally Posted by Abrham View Post
    Working with a pretty old codebase and have hit a wall during some integration testing. The code actually hasn't changed in a year or more but this error just started popping up out of nowhere.
    IMHO,that shell call, as coded will never succeed
    so,i find it very strange it has ever worked
    do not put off till tomorrow what you can put off forever

  19. #19
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,842

    Re: VB6 Invalid Procedure Call or Argument

    Ahhh Abrham, I now understand. And yes, I often find myself in similar situations. My primary application is typically executed off of a network server, being run by many machines on the LAN. Occasionally, I will have one specific computer on the LAN that gets an error. It doesn't happen on my personal development machine, and it doesn't happen on a networked computer I've been assigned.

    Therefore, my only alternative is to install the VB6 IDE on the computer generating the error.

    That sounds a bit different from your situation, but not far off.

    In those cases, I'll agree; I wouldn't know how to proceed without installing the IDE on the offending machine. Through the years, I have solved problems this way many times.

    Just thinking about it, I'm assuming they won't give you "Local Administrative Rights" on the computer causing the error. I have a couple of ideas. First, I'd try my best that you only need LOCAL administrative rights (just for that machine), and not NETWORK administrative rights.

    Secondly, there's a copy of the VB6 IDE floating around that's called "Portable". Some guy worked really hard to cobble together a minimal set of .EXE and .DLL files needed to run the VB6 IDE. It'll actually execute off of a thumb drive. I don't use it often, but it's sort of cool. It's particularly nice in that no "installation" of the IDE is required to run it. There used to be links to it floating around, but I'll leave you on your own regarding that (and also, I'm quite sure posting it here would cause this link to be deleted by the moderators because I'm sure that "portable" IDE isn't properly licensed).


    On this issue of the "Shell" statement, it truly puzzles me why MarkT and IkkeEnGij have a problem with it. Maybe they know something about the RMStanfinOblig.exe and how it accepts command line arguments. If that's the case, I'll defer to their expertise. However, I still fail to see how that would cause a problem for the VB6 code snippet posted in post #1.

    Do MarkT and IkkeEnGij think that that Shell command won't compile in VB6? If that's the case, just start a new standard module, delete the Option Explicit (or declare some temp variables to cover the bases), and then put this code into it:

    Code:
    Sub test()
        Shell """" & msReportPath & "RMStanfinOblig.exe""" & " " & _
                sCookie & "," & msServer & "," & msDatabase & _
                "," & msUserOrgId & "," & msFileNamesTx, vbNormalFocus
    End Sub
    It'll compile and/or run absolutely fine. Is there confusion how to get a quote mark into a string? Is there confusion about some of those commas that are embedded in the strings being erroneously interpreted as specifying additional arguments to the Shell command? Again, I don't see why there's so much focus on this correctly composed Shell statement.

    Regards To All,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  20. #20
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: VB6 Invalid Procedure Call or Argument

    yes,you'r right,i see that now,my bad
    do not put off till tomorrow what you can put off forever

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width