Guest User

Visual Basic Tutorial (Youtube)

a guest
Jan 23rd, 2011
7,323
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim OpenDLG As New OpenFileDialog
  2.  
  3. OpenDLG.Filter = "Text Files (*.txt)|*.txt|All Files|*.*"
  4. OpenDLG.Title = "Open File"
  5. OpenDLG.InitialDirectory = "C:\"
  6. OpenDLG.RestoreDirectory = True
  7.  
  8. DialogResult = OpenDLG.ShowDialog
  9.  
  10. If DialogResult = Windows.Forms.DialogResult.OK Then
  11.  
  12. Dim objreader As New System.IO.StreamReader(OpenDLG.FileName)
  13.  
  14. TextBox1.Text = objreader.ReadToEnd
  15.  
  16. objreader.Close()
  17.  
  18. Me.Text = "Notepad | " + OpenDLG.FileName
  19. Label1.Text = OpenDLG.FileName.ToString()
  20.  
  21. ElseIf DialogResult = Windows.Forms.DialogResult.Cancel Then
  22.  
  23. End If
RAW Paste Data