vb.net 点击Label获取连接字符串

前端之家收集整理的这篇文章主要介绍了vb.net 点击Label获取连接字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
 Private Sub Label1_Click(sender As Object,e As EventArgs) Handles Label1.Click
        Dim myStream As System.IO.Stream
        OpenFileDialog1.InitialDirectory = "C:\Users\Administrator\Desktop"
        OpenFileDialog1.Filter = ""
        OpenFileDialog1.FilterIndex = 2
        OpenFileDialog1.RestoreDirectory = True
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Try
                Label1.ForeColor = Color.White
                Label1.Text = OpenFileDialog1.FileName
                myStream = OpenFileDialog1.OpenFile()
                If Not (myStream Is Nothing) Then
                    g_sqlDataSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Label1.Text + ""
                    myStream.Close()
                End If
            Catch ex As Exception
                MsgBox("错误!")
            End Try
        End If
    End Sub

猜你在找的VB相关文章