Utilize multiple values upon starting up a VB.NET Windows application?

Posted on 2011-02-15
Last Modified: 2012-05-11

I'm trying to change my .exe program to have more than one value passed to the program.  But I get a Value of type 'String' cannot be converted to '1-dimensional array of Boolean' with line item:  bOpen = returnValue(2).ToString

I understand returnValue(1) will give me the parameter when running this .exe - all I"m trying to do is have a second parameter true or false.  The first parameter will be a file I want to adjust and the second parameter will tell the computer to open the file when finished but only do so if the value is true.

Thank you for any help - much appreciated.
Private Sub frmMain_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown

    Dim returnValue As String()
    Dim bOpen As String()
    returnValue = Environment.GetCommandLineArgs()
    If returnValue.Length > 1 Then
      txtFile.Text = returnValue(1).ToString
        bOpen = returnValue(2).ToString
      Catch ex As Exception

      End Try
      btnBrowse.Visible = False

      Call Start_Process(returnValue(1).ToString, True)


      txtFile.Text = "Q:\EC"

    End If

  End Sub

Open in new window

Question by:stephenlecomptejr
LVL 52

Accepted Solution

Carl Tawn earned 500 total points
ID: 34900103
You have "bOpen" delcared as an array, but you are only pulling a single value from the command line arguments array. You should just need to change the line:
Dim bOpen As String()

Open in new window

Dim bOpen As String

Open in new window

Not sure why it's complaining about Boolean, unless there was a type in your code an "bOpen" is actually a Boolean array.

Author Comment

ID: 34900774
fyi THE Start_Process code is:
Private Sub Start_Process(ByVal sDatabase As String, ByVal bOpen As Boolean)

    txtFile.BackColor = Color.WhiteSmoke
    lblArchiving.Visible = True
    Me.Cursor = Cursors.WaitCursor

    If Archive_File(sDatabase) = False Then

      Me.Cursor = Cursors.Default
      btnBrowse.Visible = True
      MessageBox.Show("Was not succesful in archiving database.  Please have database admin give it a try.  Sorry.")

      Exit Sub

    End If

    If bOpen = True Then

      Me.Cursor = Cursors.Default

    End If

  End Sub

Private Sub Open_Access_Database(ByVal sDatabase As String)

    Dim sMsg As String
    Dim i As Integer

    sMsg = sDatabase & ": existed: " & File.Exists(sDatabase)


    Catch exError As Exception

      For i = 1 To 500




      Catch ex As Exception
        'ErrorMessageString = exError.ToString & " - " & exError.Message
        'Call ExceptionClassObject.WriteExceptionErrorToFile(ExceptionErrorFileString, Me.Name, sMsg, ErrorMessageString, WriteErrorMessageString)

      End Try

    End Try

  End Sub

Open in new window


Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 47
Batch file or script with password 22 44
get row value in 4 14
Powershell File Sort 8 31
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

809 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