?
Solved

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

Posted on 2011-02-15
2
Medium Priority
?
342 Views
Last Modified: 2012-05-11
All,

I'm trying to change my VB.net .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
      Try
        bOpen = returnValue(2).ToString
      Catch ex As Exception

      End Try
      btnBrowse.Visible = False

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

    Else

      txtFile.Text = "Q:\EC"

    End If


  End Sub

Open in new window

0
Comment
Question by:stephenlecomptejr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 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

To:
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.
0
 
LVL 1

Author Comment

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

    txtFile.BackColor = Color.WhiteSmoke
    Application.DoEvents()
    lblArchiving.Visible = True
    Application.DoEvents()
    Me.Cursor = Cursors.WaitCursor
    Application.DoEvents()

    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.")
      Application.Exit()

      Exit Sub

    End If

    If bOpen = True Then

      Open_Access_Database(sDatabase)
      Me.Cursor = Cursors.Default
      Application.Exit()

    End If

  End Sub

Private Sub Open_Access_Database(ByVal sDatabase As String)

    Dim sMsg As String
    Dim i As Integer

    System.Windows.Forms.Application.DoEvents()
    sMsg = sDatabase & ": existed: " & File.Exists(sDatabase)
    Try

      Process.Start(sDatabase)

    Catch exError As Exception

      For i = 1 To 500

      Next

      Try

        Process.Start(sDatabase)

      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

0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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