Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. notepad

notepad

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peteyshrew
    wrote on last edited by
    #1

    i am creating a notepad in vs05 and i am trying to display the name of the file at the top of the screen when i open a file from desktop. this is the code i've got so far, instead of the file name it displays openfiledialog1. this is very anoying, any help would be appreciated. thanks this is code i got: Dim name As String = OpenFileDialog1.FileName With OpenFileDialog1 .Title = "select file" .InitialDirectory = "U:\MyDocuments" .DefaultExt = "rtf" .Filter = "rich text files(*.rtf)|*.rtf" .FilterIndex = 1 End With OpenFileDialog1.ShowDialog() If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtb1.LoadFile(OpenFileDialog1.FileName) Else MsgBox.show("unknown error during file read") End If Me.Text = name

    P 1 Reply Last reply
    0
    • P peteyshrew

      i am creating a notepad in vs05 and i am trying to display the name of the file at the top of the screen when i open a file from desktop. this is the code i've got so far, instead of the file name it displays openfiledialog1. this is very anoying, any help would be appreciated. thanks this is code i got: Dim name As String = OpenFileDialog1.FileName With OpenFileDialog1 .Title = "select file" .InitialDirectory = "U:\MyDocuments" .DefaultExt = "rtf" .Filter = "rich text files(*.rtf)|*.rtf" .FilterIndex = 1 End With OpenFileDialog1.ShowDialog() If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtb1.LoadFile(OpenFileDialog1.FileName) Else MsgBox.show("unknown error during file read") End If Me.Text = name

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Replace Me.Text = name with Me.Text = OpenFileDialog1.FileName. Actually, you would be better writing this section like this:

      Dim fileName As String
      
      If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
          fileName = OpenFileDialog1.FileName
      End If
      
      If fileName <> String.Empty Then
          rtb1.LoadFile(fileName)
          Me.Text = fileName
      End If
      

      Don't tell somebody that there was an unknown error just because they clicked Cancel in a dialog box. It is bad form.

      the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
      Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups