腾讯体育nba解说嘉宾:问一个vb的问题

来源:百度文库 编辑:高校问答 时间:2024/05/04 23:56:29
在vb中编写了一个打开文件的对话框,如果要使它点击jpg格式的文件时自动用form4进行图片浏览,那么这个步骤的命令应该怎么编写?告诉我源代码!谢谢!(以下是现有的源代码)

Dim setfilename As String
———————————————
Private Sub Command1_Click()
RetVal = Shell(setfilename, 1)
End Sub
———————————————
Private Sub Command2_Click()
Text1.Text = ""
End Sub
———————————————
Private Sub Command3_Click()
msg = MsgBox("确定退出吗?", 4)
If msg = vbYes Then
End
End If
End Sub
———————————————
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Text1.Text = File1.Path
End Sub
———————————————
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
———————————————
Private Sub Exit_Click()
End
End Sub
———————————————
Private Sub File1_Click()
If (Right(File1.Path, 1)) = "\" Then
setfilename = File1.Path & File1.FileName
Text1.Text = Dir1.Path & File1.FileName
Else
setfilename = Dir1.Path & "\" & File1.FileName
Text1.Text = Dir1.Path & "\" & File1.FileName
End If
End Sub
———————————————
Private Sub File1_DblClick()
Form4.Show
Unload Form1
RetVal = Shell(setfilename, 1)
End Sub
———————————————
Private Sub Form_Load()
Form1.Hide
Form3.Show
End Sub
———————————————
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu File
End If
End Sub
———————————————
Private Sub Helpfile_Click()
Unload Form1
Form2.Show
End Sub

做了个image筐,点file1里面的jpg文件后会在image1里显示出来。

注意 file1.pattren="*.jpg"

Private Sub Dir1_Change()
File1.Path = Dir1.Path
Text1.Text = File1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub Exit_Click()
End
End Sub

Private Sub File1_Click()
If (Right(File1.Path, 1)) = "\" Then
setfilename = File1.Path & File1.FileName
Text1.Text = Dir1.Path & File1.FileName
Else
setfilename = Dir1.Path & "\" & File1.FileName
Text1.Text = Dir1.Path & "\" & File1.FileName
End If

Image1.Picture = LoadPicture(Text1.Text)

End Sub