|
-
Apr 23rd, 2013, 06:58 PM
#1
Thread Starter
New Member
How do you display the file name and path in Me.Text ?
What I'm trying to do is put the file name and path up in the title of the form when I click on "New", "Append", "Inquiry", and "Lookup." All I get is "OpenFileDialog1" or a blank that removes the date and time and other text. I've included the code and a print screen of the form below.
Code:
Option Strict On
Imports System.IO
Public Class frmTitle
Dim outPutFile As StreamWriter
Dim inPutFile As StreamReader
Dim OutOpen, InOpen As Boolean
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Dim fpath As String = ofdOpenFile.FileName
Dim fbd As New FolderBrowserDialog
Dim mainPath As String
If fbd.ShowDialog = DialogResult.OK Then
mainPath = fbd.SelectedPath
End If
sfdSaveFile.Filter = "Inventory files (*.emp)|*.txt|All files (*.*)|*.*"
If sfdSaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
outPutFile = File.CreateText(sfdSaveFile.FileName)
End If
grpEmpData.Enabled = True
btnSave.Enabled = True
btnNext.Enabled = False
btnFind.Enabled = False
If NewToolStripMenuItem.Enabled = True Then
NewToolStripMenuItem.Enabled = False
AppendToolStripMenuItem.Enabled = False
InquiryToolStripMenuItem.Enabled = False
LookUpToolStripMenuItem.Enabled = False
CloseToolStripMenuItem.Enabled = True
'ofdOpenFile.ShowDialog = Windows.Forms.DialogResult.OK
'Me.Text = mainPath
Me.Text = ofdOpenFile.FileName
End If
-
Apr 23rd, 2013, 07:24 PM
#2
Re: How do you display the file name and path in Me.Text ?
you're not using an openfiledialog.
you have a folderbrowserdialog + a savefiledialog that you're using correctly...
Code:
Dim outPutFile As StreamWriter
Dim inPutFile As StreamReader
Dim OutOpen, InOpen As Boolean
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Dim fpath As String = ofdOpenFile.FileName
Dim fbd As New FolderBrowserDialog
Dim mainPath As String
If fbd.ShowDialog = DialogResult.OK Then
mainPath = fbd.SelectedPath
End If
sfdSaveFile.Filter = "Inventory files (*.emp)|*.txt|All files (*.*)|*.*"
If sfdSaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
outPutFile = File.CreateText(sfdSaveFile.FileName)
End If
grpEmpData.Enabled = True
btnSave.Enabled = True
btnNext.Enabled = False
btnFind.Enabled = False
If NewToolStripMenuItem.Enabled = True Then
NewToolStripMenuItem.Enabled = False
AppendToolStripMenuItem.Enabled = False
InquiryToolStripMenuItem.Enabled = False
LookUpToolStripMenuItem.Enabled = False
CloseToolStripMenuItem.Enabled = True
'ofdOpenFile.ShowDialog = Windows.Forms.DialogResult.OK
'Me.Text = mainPath
Me.Text = ofdOpenFile.FileName
End If
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|