
关于VB制作文件列表框
PrivateSubCommand1_Click()PrivateSubDir1_Change()File1.Path=Dir1.PathEndSubPrivateSub...
Private Sub Command1_Click()
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
If Err.Number > 0 Then
MsgBox "设备没有准备好!", vbCritical
End If
End Sub
Private Sub File1_Click()
Dim filename1 As String
If Right(File1.Path, 1) = "\" Then
filename1 = File1.Path & File1.FileName
Else
filename1 = File1.Path & "\" & File1.FileName
End If
Image1.Picture = LoadPicture(filename1)
End Sub
Private Sub Form_Load()
File1.Pattern = "*.jpg;*.gif;*.jpeg;*.bmp"
End Sub
Private Sub Image1_Click()
作用是浏览图片用的,请问如何同时实现将txt文件输出到一个新建的label标签上呢,如果选择图片文件同时隐去label,若选择了txt格式则隐去imagebox. 展开
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
If Err.Number > 0 Then
MsgBox "设备没有准备好!", vbCritical
End If
End Sub
Private Sub File1_Click()
Dim filename1 As String
If Right(File1.Path, 1) = "\" Then
filename1 = File1.Path & File1.FileName
Else
filename1 = File1.Path & "\" & File1.FileName
End If
Image1.Picture = LoadPicture(filename1)
End Sub
Private Sub Form_Load()
File1.Pattern = "*.jpg;*.gif;*.jpeg;*.bmp"
End Sub
Private Sub Image1_Click()
作用是浏览图片用的,请问如何同时实现将txt文件输出到一个新建的label标签上呢,如果选择图片文件同时隐去label,若选择了txt格式则隐去imagebox. 展开
推荐于2016-01-11 · 知道合伙人软件行家
关注

展开全部
文件列表框
文件列表框在运行时显示由 Path 属性指定的包含在目录中的文件。可用下列语句在当前驱动器上显示当前目录中的所有文件:
File1.Path = Dir1.Path
然后,可设置 Pattern 属性来显示这些文件的子集─ 例如,设置为 *.frm 后将只显示这种扩展名的文件。Pattern
属性也接受由分号分隔的列表。例如,下列代码行将显示所有扩展名为 .frm 和 .bas 的文件:
File1.Pattern = "*.frm; *.bas"
以下代码是实现上述要求的实例代码:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File1.Pattern = "*.frm; *.bas"
End Sub
Private Sub Form_Load()
File1.Path = Dir1.Path
File1.Pattern = "*.frm; *.bas"
End Sub
展开全部
File1.Pattern = "*.jpg;*.gif;*.jpeg;*.bmp"
这句限制了文件列表中只能显示这几种扩展名的文件
File1.Pattern="*.txt;*.jpg……
Private Sub File1_Click()
Dim filename1 As String
If Right(File1.Path, 1) = "\" Then
filename1 = File1.Path & File1.FileName
Else
filename1 = File1.Path & "\" & File1.FileName
End If
if LCase(Right(finename1,4))=".txt" then
Image1.visible=false
'然后就是打开文件,读取文本并设置Label1.Caption
else
Label1.visible=false
Image1.Picture = LoadPicture(filename1)
end if
这句限制了文件列表中只能显示这几种扩展名的文件
File1.Pattern="*.txt;*.jpg……
Private Sub File1_Click()
Dim filename1 As String
If Right(File1.Path, 1) = "\" Then
filename1 = File1.Path & File1.FileName
Else
filename1 = File1.Path & "\" & File1.FileName
End If
if LCase(Right(finename1,4))=".txt" then
Image1.visible=false
'然后就是打开文件,读取文本并设置Label1.Caption
else
Label1.visible=false
Image1.Picture = LoadPicture(filename1)
end if
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
On Error Resume Next
Err.Clear
filename1 = "jsldfjkla"
Image1.Picture = LoadPicture(filename1) '加载图片
If Err Then
'显示文本
h = FreeFile
Open filename1 For Binary Access Read As h
label1.Caption = Input(LOF(h), h)
Close h
label1.Visible = True
iamge1.Visible = False
Else
'显示图片
label1.Visible = False
iamge1.Visible = True
End If
'QQ在线:58507961
Err.Clear
filename1 = "jsldfjkla"
Image1.Picture = LoadPicture(filename1) '加载图片
If Err Then
'显示文本
h = FreeFile
Open filename1 For Binary Access Read As h
label1.Caption = Input(LOF(h), h)
Close h
label1.Visible = True
iamge1.Visible = False
Else
'显示图片
label1.Visible = False
iamge1.Visible = True
End If
'QQ在线:58507961
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询