in VB.net about list box, i have a doubt

if we need to browse a file from a open file option


how to select a file from the open option and only name of the file should be written on the button

and by clicking on the button u should be able to open file

the file can be .exe, .doc and any type of file

Edited by skp03: n/a

5 Years
Discussion Span
Last Post by codeorder

See if this helps, 2Buttons.needed.

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With Button1 : .Text = ".open" : End With : With Button2 : .Text = ".fileName" : .Width += 123 : End With '// FOR TESTING.
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        With New OpenFileDialog
            .Title = "Select a Cool File to load..."
            ' .Filter = ""
            If .ShowDialog = Windows.Forms.DialogResult.OK Then
                Button2.Text = IO.Path.GetFileName(.FileName) '// only FileName and .ext.
                Button2.Tag = .FileName '// FullPath of .File, to load .File from.
            End If
        End With
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        With Button2
            If Not .Tag Is Nothing Then Process.Start(.Tag.ToString) '// check if it has a .FullPath and load in/as default.
        End With
    End Sub
End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.