0
私はこのコードを関数にして、いくつかのパラメータを変更して再利用できるようにしたいと思います。オープンファイルダイアログを作成する複数回使用する関数
これはだから私はやることができません唯一のものはdialogBox2
かdialogBox3
にしてdialogBox1
テキストを変更することで、これまで私が持っているもの
Sub OpenFiles(InFile As IO.StreamReader, verifytheFileName As String,dialogBoxTitle As String)
Dim result As DialogResult
Dim FilePath As String
Dim FileName As String
Try
dialogBox1.Title = dialogBoxTitle
dialogBox1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
result = dialogBox1.ShowDialog 'Open This Dialog Box
FilePath = dialogBox1.FileName 'Gets the Path of the file and stores it in File Path Varible
FileName = dialogBox1.SafeFileName 'Gets the name of the file and stores it in File Name Varible
If Not FileName = verifytheFileName Then
MessageBox.Show("Please Select " &verifytheFileName)
dialogBox1.Reset()
Else
InFile = IO.File.OpenText(FilePath)
End If
Catch ex As Exception
MessageBox.Show("ERROR")
End Try
End Sub
です。あなたはそれを変更する必要がありますなぜ私はこの
機能しますか?あなたが複数のFileOpenダイアログを同時に開くことを望んでいない限り、それはそのままでうまくいくでしょう。これは意味をなさないもので、複数のスレッドからのみ可能です。 – GSerg
私はいくつかのボタンを開いています異なる種類のファイル – jake123
とにかくそれらを一度に押すことはできません。すでに 'Title'を渡しているように' Filter'をパラメータとして渡すだけです。 – GSerg