热心网友
回答时间:2025-01-11 14:59
窗体画file、button、textbox各一个,窗体代码如下:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
If Command1.Caption <> "未找到" Then
ShellExecute Me.hwnd, "open", File1.Path & "\" & File1.FileName, vbNullString, vbNullString, 3
End If
End Sub
Private Sub File1_Click()
If File1.ListCount > 0 Then
Command1.Caption = File1.FileName
Else
Command1.Caption = "未找到"
End If
End Sub
Private Sub Form_Load()
File1.Path = "F:\CnccoAgricultural文档"
Text1.Text = ""
End Sub
Private Sub Text1_Change()
'模糊查询,docx为word2007
File1.Pattern = "*" & Text1.Text & "*.doc;*" & Text1.Text & "*.docx" '仅限word
If File1.ListCount > 0 Then
File1.ListIndex = 0 '下标从0开始
End If
End Sub
========================================
是vb6
收起