Kirk Charles Niverba Kirk Charles Niverba - 1 year ago 53 Question

How to open a file with Visual Basic?

I'm making a application opener on Visual Basic, and this idea comes into my mind. What if the file isn't accessible, what would the application do? If the file isn't accessible or it isn't found: a message box will show (note that this is VB on 2012 Version).

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
End Class


I would use try/catch sentences

Catch ex As Exception
    MsgBox("Can't access file " & vbCrLf & ex.Message)
End Try

If you canĀ“t access the file the message will be shown