①设置文件控件File1和图像控件Image1的属性。
Private Sub Form_Load() '这是为File和Image控件设置属性
File1.Pattern = "*.bmp"
Image1.Stretch = True
End Sub
②在编写的二个过程代码Dir1_Change(),File1_Click()中各有一处错误,请调试改正。
Private Sub Dir1_Change()
File1.Path = Dir1.Path '将Dir1.Drive改成Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Dim fname As String
If Right(Dir1.Path, 1) = "\" Then
fname = Dir1.Path & File1.FileName
Else
fname = Dir1.Path & "\" & File1.FileName
End If
Image1.Picture = LoadPicture(fname) '为fname加上LoadPicture函数
End Sub