| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2866 人关注过本帖
标题:请教:错误的参数号或无效的属性赋值
只看楼主 加入收藏
anywaycc
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:3 
请教:错误的参数号或无效的属性赋值


Private Sub Form_Load()
ListView1.ColumnHeaders.Add 1, , "名称", ListView1.Width / 4
ListView1.ColumnHeaders.Add 2, , "路径", ListView1.Width / 3, 0
ListView1.ColumnHeaders.Add 3, , "大小", ListView1.Width / 6, 1
ListView1.ColumnHeaders.Add 4, , "修改时间", ListView1.Width / 4, 0
End Sub


Private Sub Command1_Click()
If Text1.Text <> "" Then
If InStr(1, Text1.Text, "*") = 0 Then
Text1.Text = Text1.Text + "*.*"
End If
ListView1.ListItems.Clear
Form1.Height = 6810
ListView1.Visible = True
Form1.Refresh
strres = Dir(Drive1.Drive + "\" + Text1.Text)
Do While strres <> ""
Dim li As ListItem
Set li = ListView1.ListItems.Add(, , strres)
ListView1.ListItems(li.Index).ListSubItems.Add , , Drive1.Drive + "\"
Set ufile = fs1.GetFile(Drive1.Drive + "\" + strres)
dxstr = Format(Int(ufile.Size / 1024), "###,###") + "KB"
If dxstr = "KB" Then
dxstr = "1KB"
End If
ListView1.ListItems(li.Index).ListSubItems.Add , , dxstr
ListView1.ListItems(li.Index).ListSubItems.Add , , Str(ufile.DateLastModified)
strres = Dir
Loop
ListView1.Refresh
If Check1.Value = 1 Then
Findfolder Drive1.Drive + "\"
End If
Else
MsgBox "请输入搜索内容", vbOKOnly, "警告"
End If

End Sub


Private Function Findfolder() As String

Dim fld As Folder
Dim subfld As Folder
Dim strres As String
Set fld = fsl.GetFolder(pathstr)
Set fld = fld.SubFolders
If flds.Count > 0 Then
For Each subfld In flds
strres = Dir(subfld.Path + "\" + Text1.Text)
Do While strres <> ""
Dim li As ListItem
Set li = ListView1.ListItems.Add(, , strres)
ListView1.ListItems(li.Index).ListSubItems.Add , , subfld.Path
Set ufile = fsl.GetFile(subfld.Path + "\" + strres)
dxstr = Format(Int(ufile.Size / 1024), "###,###") + "KB"
If dxstr = "KB" Then
dxstr = "1KB"
End If
ListView1.ListItems(li.Index).ListSubItems.Add , , dxstr
ListView1.ListItems(li.Index).ListSubItems.Add , , Str(ufile.DateLastModified)
ListView1.Refresh
strres = Dir
Loop
Findfolder subfld.Path
Next
End If

End Function
请教高手,编辑时在红色代码那儿提示错误的参数号或无效的属性赋值,应该怎么改,望各位给予指点,不胜感激!

搜索更多相关主题的帖子: 赋值 属性 
2007-05-10 17:57
Joforn
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1242
专家分:122
注 册:2007-1-2
收藏
得分:0 
Private Function Findfolder() As String
你这里没有定义参数,在调用的时候Findfolder Drive1.Drive + "\"肯定是错误的啊。

VB QQ群:47715789
2007-05-10 19:41
hyhhd
Rank: 2
等 级:论坛游民
威 望:1
帖 子:502
专家分:44
注 册:2006-5-12
收藏
得分:0 

按你的意思,“Findfolder”应该写为过程,而不是函数。函数应该有返回值才对!


2007-05-10 19:55
anywaycc
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-5-10
收藏
得分:0 
感激不尽
设了参数过后,指示Set fld = fsl.GetFolder(pathstr)这句说要求对象,
刚接触VB,拜托各位高手可以写详细点不
2007-05-10 20:18
快速回复:请教:错误的参数号或无效的属性赋值
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013259 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved