Getting a File Path

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Baladin
    New Member
    • Feb 2008
    • 14

    Getting a File Path

    Hi,

    I've got a form (in Vb Express 2008) which has a TextBox and a Button saying Browse

    I've managed to get the form to open the Open Dialogue when I press the Browse button, and I can use that to select the .mdb file I want, but how can I get the file path (ie. E:/Comp/Database/records.mdb) into the text box?

    cheers if you can help
  • leeogrady
    New Member
    • Jun 2008
    • 11

    #2
    Basically the following, however this does not account for erronus data etc..

    Code:
        Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
            If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
                FilePath.Text = OpenFileDialog1.FileName.ToString()
            End If
        End Sub
    Above code is assuming;
    • the button to 'browse' is called Browse
    • the file dialog is called OpenFileDialog1
    • the FilePath text box is where the path is to be placed


    Hope this helps
    Lee

    Comment

    • Baladin
      New Member
      • Feb 2008
      • 14

      #3
      that simple? suppose its all about knowing the right commands, cheers i'll give that a go

      Comment

      • FRANCOFABIAN
        New Member
        • Jun 2008
        • 2

        #4
        Hello, will this code work for visual basic in excel?

        Saludos

        Comment

        • Baladin
          New Member
          • Feb 2008
          • 14

          #5
          great, that worked, cheers, now the tedious bit, copying and moving data, thanks again

          Comment

          • daniel aristidou
            Contributor
            • Aug 2007
            • 494

            #6
            Originally posted by Baladin
            great, that worked, cheers, now the tedious bit, copying and moving data, thanks again
            Hi baladin.....the best way to deal with moving and copying data is by using snippets. Right click where you want to place the code and select add snippet, then locate your way around the menu provided until you find the code you need

            Comment

            Working...