Link to home
Start Free TrialLog in
Avatar of stephenlecomptejr
stephenlecomptejrFlag for United States of America

asked on

Trying to pass two parameters to an VB.NET .exe program from Microsoft Office Access VBA 2007 but not working?

Per the following code, I'm trying to pass two values to an .exe that will modify an Access database and then based on the second value, open the database when finished.  But when I run the vba below I keep getting an error on the .exe file that states:

Unhandled exception has occured in your application.  If you click continue the application will ignore this error and attempt to continue.  If you click QUit, the application will close immediately.

Input string was not in a correct format.

The vb.net file I'm trying to run with its code can be found at this link:
https://www.experts-exchange.com/questions/26823374/Utilize-multiple-values-upon-starting-up-a-VB-NET-Windows-application.html

I'm pretty sure the Access VBA is correct but not sure on the Visual Basic.NET side?

WIth Details stating:

ee the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.FormatException: Input string was not in a correct format.
   at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat)
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(String Value)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
Archive_EC_database
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///Q:/EC/0MSAccess/Features/Archive_EC_database.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.



Public Declare Function StartupShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Public Function Open_Archiving()
On Error GoTo Err_This

  Dim sNameOnly As String
  sNameOnly = Right(CurrentDb.Name, Len(CurrentDb.Name) - InStrRev(CurrentDb.Name, "\"))

  Call StartupShellExecute(0&, "Open", sArchiveEXE, Chr(34) & Network_Path(CurrentDb.Name) & sNameOnly & Chr(34), True, 1)

Exit_This:
  Exit Function

Err_This:
  Call Error_Action(Err, Err.description, "modRibbon @ Open_Archiving", Erl())
  Resume Exit_This

End Function

Open in new window

Avatar of ToddBeaulieu
ToddBeaulieu
Flag of United States of America image

You've got this filed under VB.net, but this looks like VBA.

I  don't have VB to try this and it's an awfully long time...

First off, I think you have your arguments off.

You're passing in  < true, 1 > as the last two args, but the API's looking for a string and a bool. Obviously, that's not right. I'd start there.

Next up, you are supposed to pass all args in a single string with a space between them. Again, I can't test this, but I worry about directories and filenames with spaces in them. I'm not sure what to do there. I don't know if it wants quotes around the filename (in case of spaces), a space and then the second arg. I don't think you need to quote the entire string.

Anyway, you're not passing two args up there, you're just passing one, with the invalid string arg, which is most likely the cause of the exception.
Avatar of stephenlecomptejr

ASKER

So Todd,

Some things that could help me further-

If I were to utilize one command line via Run - what should the syntax be for DOS?
And if it were another vb.net calling another .exe what should be the syntax be for such whereby I change the vb.net coding (shown on the other URL)?
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both were right.  Code Cruiser helped me see that another section of code was causing a problem.  I appreciate Todd's help and initiative in solving the other part of where I still had to adjust the startup code the right way.   Without his input, I never would have come close to solving this issue.

Much appreciation.