FileListBox 多选的问题

liyujie2000 2004-07-28 03:42:03
请问如何取得在 FileListBox 里面(多选)选中的多个文件的文件名。


---------------
我是菜鸟,大家轻点拍砖。
...全文
199 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainstormmaster 2004-07-28
  • 打赏
  • 举报
回复
用api速度可以快一些:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_GETSELITEMS = &H191
Private Const LB_GETSELCOUNT = &H190

Private Sub Command1_Click()
Dim items() As Long
Dim numsel As Long
Dim c As Long
Dim retval As Long

numsel = SendMessage(File1.hwnd, LB_GETSELCOUNT, ByVal CLng(0), ByVal CLng(0))
If numsel = 0 Then
Debug.Print "没有文件被选中"
Else

ReDim items(0 To numsel - 1) As Long
retval = SendMessage(File1.hwnd, LB_GETSELITEMS, ByVal numsel, items(0))
' Display them.
Debug.Print "选中了以下文件:"
For c = 0 To UBound(items)
Debug.Print File1.List(items(c))
Next

End If
End Sub
liyujie2000 2004-07-28
  • 打赏
  • 举报
回复
帖子已经结了,分也给出去了
怎么浏览起来还是显示0分啊?


=================================================================================

回复人:online(龙卷风V2.0--再战江湖) () 信誉:267 2004-7-28 15:53:01 得分: 30 删除

Private Sub Command2_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then
MsgBox File1.List(i)
End If
Next
End Sub

回复人:online(龙卷风V2.0--再战江湖) () 信誉:267 2004-7-28 15:53:44 得分: 0 删除

file1的multiselect选择2-extended

回复人:gdami(糖米) () 信誉:110 2004-7-28 15:55:42 得分: 10 删除

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount-1
If File1.Selected(i) = True Then
Text1.Text = Text1.Text & " " & File1.List(i)
End If
Next i
End Sub


看他的file1.selected(file1.listindex)是不是真值,是就用
file1.list(file1.listindex)得到.

回复人:TechnoFantasy(冰儿马甲www.applevb.com) () 信誉:159 2004-7-28 15:57:00 得分: 10 删除

通过List属性访问

回复人:liyujie2000(开心的鱼) () 信誉:100 2004-7-28 16:00:36 得分: 0 删除

哇塞,这个地方热心人真多,一下子就回了几个贴了。

搞定了,多谢!

回复人:liyujie2000(开心的鱼) () 信誉:100 2004-7-28 16:03:43 得分: 0 删除

怎么啦,结贴的时候出现异常?


(选择回复人前面的复选框,点击“删除选择的回复”按钮可批量删除回复)


liyujie2000 2004-07-28
  • 打赏
  • 举报
回复
怎么啦,结贴的时候出现异常?
liyujie2000 2004-07-28
  • 打赏
  • 举报
回复
哇塞,这个地方热心人真多,一下子就回了几个贴了。

搞定了,多谢!
TechnoFantasy 2004-07-28
  • 打赏
  • 举报
回复
通过List属性访问
gdami 2004-07-28
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount-1
If File1.Selected(i) = True Then
Text1.Text = Text1.Text & " " & File1.List(i)
End If
Next i
End Sub


看他的file1.selected(file1.listindex)是不是真值,是就用
file1.list(file1.listindex)得到.
online 2004-07-28
  • 打赏
  • 举报
回复
file1的multiselect选择2-extended
online 2004-07-28
  • 打赏
  • 举报
回复
Private Sub Command2_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then
MsgBox File1.List(i)
End If
Next
End Sub

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧