K
Kelly
Ok, I need a little help. So far, I've written a program that will allow
a user to browse for a file (via a dialog box) and open the selected file. I
need to make some slight modifications to that and have the user's data
(entered into a textbox) saved to a selected file (from the dialog
box)...here's what I have done so far. I was hoping that someone could steer
me in the right direction. Thanks!
Dim myFileDlog As New OpenFileDialog
myFileDlog.InitialDirectory = "C:\"
myFileDlog.Filter = "Text Files |*.txt|All files | *.*"
If myFileDlog.ShowDialog() = DialogResult.OK Then
Dim sFileName As String = myFileDlog.FileName
Dim sFileExtension As String = (sFileName.Substring(sFileName.Length - 4))
Select Case sFileExtension.ToUpper
Case ".TXT"
Shell("notepad.exe " & sFileName, AppWinStyle.MaximizedFocus)
Case ".DOC"
Shell("path to word.exe goes here" & sFileName, AppWinStyle.MaximizedFocus)
Case ".XLS"
Shell("path to excel.exe goes here " & sFileName,
AppWinStyle.MaximizedFocus)
Case Else
MsgBox("not a valid file extension")
End Select
Else
MsgBox("User pressed Cancel.")
End If
a user to browse for a file (via a dialog box) and open the selected file. I
need to make some slight modifications to that and have the user's data
(entered into a textbox) saved to a selected file (from the dialog
box)...here's what I have done so far. I was hoping that someone could steer
me in the right direction. Thanks!
Dim myFileDlog As New OpenFileDialog
myFileDlog.InitialDirectory = "C:\"
myFileDlog.Filter = "Text Files |*.txt|All files | *.*"
If myFileDlog.ShowDialog() = DialogResult.OK Then
Dim sFileName As String = myFileDlog.FileName
Dim sFileExtension As String = (sFileName.Substring(sFileName.Length - 4))
Select Case sFileExtension.ToUpper
Case ".TXT"
Shell("notepad.exe " & sFileName, AppWinStyle.MaximizedFocus)
Case ".DOC"
Shell("path to word.exe goes here" & sFileName, AppWinStyle.MaximizedFocus)
Case ".XLS"
Shell("path to excel.exe goes here " & sFileName,
AppWinStyle.MaximizedFocus)
Case Else
MsgBox("not a valid file extension")
End Select
Else
MsgBox("User pressed Cancel.")
End If