Files
Each section of code below can be highlighted, copied, and pasted into VB
It should work!
Image of Form
Option Explicit
Private Sub dirDrive_Change()
filDirect.Path = dirDrive.Path
End Sub
Private Sub drvMyC_Change()
Dim retN As Integer
Dim msg As String
On Error GoTo drvError
dirDrive.Path = drvMyC.Drive
Exit Sub
drvError:
'if select drive that cannot be accessed ( error 68 )
'then reset Drive to C:
msg = "Drive selected is not Available - try another!"
Select Case Err.Number
Case 68
retN = MsgBox(msg, vbRetryCancel, "Drive Error")
If retN = vbRetry Then
'try again
Else
drvMyC = drvMyC.List(1)
Resume Next
End If
Case Else
msg = Err.Number & ": " & Err.Description
MsgBox msg, vbOKOnly, "Error"
End Select
End Sub
Private Sub filDirect_Click()
txtFile.Text = filDirect.FileName
'next line will read in default directory only ,otherwise an error
'rtfFile.LoadFile filDirect.FileName
'next line will read from any directory
'filDirect.Path holds the Dive and Directory
'need a "\" to separate directory from Filename
'fileDirect.Filename holds the filename to be dispalyed
'raw display -> tries to diaplay in ASCII format no matter what the
'files is!!
rtfFile.LoadFile filDirect.Path & "\" & filDirect.FileName
End Sub