2 Replies - 884 Views - Last Post: 02 April 2011 - 04:13 PM Rate Topic: -----

#1 astroshark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 25-November 09

trying to call an array from another function

Posted 30 March 2011 - 02:31 PM

I'm trying to call an array from another function into an argument command for a command prompt, but I have no clue on how to do so.

This code is the code where I am calling the command prompt and adding arguments
    Private Sub ConvertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConvertButton.Click
        Using m_Process As New Process()
            With m_Process.StartInfo
                .FileName = "cmd.exe"
                .UseShellExecute = False
                .CreateNoWindow = True
                .Arguments = CLIBrowse.SelectedPath & "-i " & SourceBrowse.SelectedPath & "-o " & DestinationBrowse.SelectedPath & CustomBox.Text
            End With

            m_Process.Start()
            m_Process.WaitForExit(5000)
        End Using
    End Sub



This is the code that contains the array from a combobox
    Private Sub LanguageBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanguageBox.SelectedIndexChanged
        Dim Lan(1) As String
        Lan(0) = "eng"
        Lan(1) = "jpn"
        For i = 0 To 1
            LanguageBox.SelectedIndex = Lan(i)
        Next
    End Sub
End Class



Now what I specifically want to do with this code is add the value from the combo box to the command line argument like so
                .Arguments = CLIBrowse.SelectedPath & "-i " & SourceBrowse.SelectedPath & "-o " & DestinationBrowse.SelectedPath & CustomBox.Text & "VALUE FROM COMBO BOX GOES HERE"



Is This A Good Question/Topic? 0
  • +

Replies To: trying to call an array from another function

#2 weirddemon  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 190
  • Joined: 05-January 09

Re: trying to call an array from another function

Posted 02 April 2011 - 02:21 PM

Just declare the array globally. Instead of in the methods, declare it within the class.

Class1

Private array1 as Array 'or whatever

Private Sub one(...)
'Use array
End Sub

Private Sub two (...)
'Use array
End Sub

End Class

Was This Post Helpful? 0
  • +
  • -

#3 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: trying to call an array from another function

Posted 02 April 2011 - 04:13 PM

First of all, selectedIndex property is of type int and you try to assign ot a string value. Also, to get the selected value from combobox, you can use selectedValue or SelectedText properties
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1