创建一个要多次使用的打开文件对话框功能

时间:2016-10-09 07:37:36

标签: vb.net

我有这段代码,我想把它变成一个函数,所以我可以通过改变一些参数来重用它。

所以这就是我到目前为止的作品

dialogBox2

所以我唯一无法做的就是将dialogBox3文字更改为public class MyDBContext: DbContext { public MyDBContext(): base("YourConnectionString") { //This is default initializer Database.SetInitializer<MyDBContext>(new CreateDatabaseIfNotExists<MyDBContext>()); } public DbSet<Pet> Pets { get; set; } public DbSet<Customer> Customers { get; set; } } ServerName example.tk WSGIDaemonProcess blog python-home=/home/nidhinjames/djangosite/virtualenv3.5 python-path=/home/nidhinjames/djangosite/mysite WSGIScriptAlias /djangosite /home/nidhinjames/djangosite/mysite/mysite/wsgi.py process-group=blog application-group=%{GLOBAL} WSGIDaemonProcess rnd python-home=/home/nidhinjames/djangocms/virtualenv3.5 python-path=/home/nidhinjames/djangocms/september WSGIScriptAlias / /home/nidhinjames/djangocms/september/september/wsgi.py process-group=rnd application-group=%{GLOBAL}

请告知我如何完成这项工作

1 个答案:

答案 0 :(得分:1)

在参数功能

中传递对话框
Sub OpenFiles(InFile As IO.StreamReader, verifytheFileName As String,dialogBoxTitle As String, dialogBox1 as System.Windows.Forms.SaveFileDialog)
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