次のコードがあります-開始する前に、サブルーチンにあるいくつかの変数をプリセット/初期化したいです。(具体的には、制御ファイルを読み取り、開始フォルダーの検索パスなど、いくつかの変数を事前に読み込みます)。どうすればいいですか?
パブリック クラス Form1
<STAThread()> _
Shared Sub Main()
Dim mainWindow As Form1 = New Form1()
MessageBox.Show("Hello! I'm exectuing!")
' This next line generates an error.
' I don't know how to set this variable in Main.
' How do I set up variables, perhaps from a control file ?
openFileDialog1.InitialDirectory = "c:\mypath"
Application.Run(mainWindow)
End Sub
Private Sub FindButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles FindButton.Click
' Displays an OpenFileDialog so the user can select a Cursor.
Dim openFileDialog1 As New OpenFileDialog()
' Filter by All Files
openFileDialog1.Filter = "All Files|*.*"
openFileDialog1.Title = "Process a File"
If openFileDialog1.ShowDialog() = DialogResult.OK Then
If openFileDialog1.CheckPathExists Then
If openFileDialog1.CheckFileExists Then
' do stuff with the file here
Else
StatusLabel.Text = "Path does not exist"
End If
Else
StatusLabel.Text = "openFileDialog1.ShowDialog error"
End If
End Sub
クラス終了