[Vb & C# .net] Browse command

Discussion in 'Mixed Languages' started by flare4000, Oct 31, 2010.

  1. flare4000

    flare4000 MDL Senior Member

    Apr 23, 2010
    414
    111
    10
    #1 flare4000, Oct 31, 2010
    Last edited by a moderator: Apr 20, 2017
    To help get started I will be contributing a way to browse for a file in both vb.net and c#.net
    Here is the code for
    vb.net
    Code:
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim ofd As New OpenFileDialog
            ofd.Filter = "All Files (.)|*.*"
            ofd.Title = "Select File"
            If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                TextBox1.Text = ofd.FileName
            End If
        End Sub
    c#
    Code:
    private void Button1_Click(System.Object sender, System.EventArgs e)
      {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "All Files (.)|*.*";
                ofd.Title = "Select File";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    TextBox1.Text = ofd.FileName;
                }
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...