关于For Each 的问题。

rushing 2002-07-16 03:37:04
总是出:“434 要求对象”的错误。
代码如下:

ShareRoot = "WinNT://"

Set fserv = GetObject("WinNT://pc14/LanmanServer")
Set share = fserv.Create("fileshare", "DWNLDShare")

For Each share In fserv
If share.Path = Text1.Text Then
MsgBox share.Name + " " + share.Path
End If

Next share

我用的是WIN2000 Server
...全文
35 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
rushing 2002-07-26
  • 打赏
  • 举报
回复
如果共享文件夹已经存在,没有问题。
但是如果该目录没共享,就会出错。
即for循环不能循环到底。
96151024 2002-07-18
  • 打赏
  • 举报
回复
你在执行For Each share In fserv之前检查一下fserv的内容,肯定是空的


Set fserv = GetObject("WinNT://pc14/LanmanServer")
Set share = fserv.Create("fileshare", "DWNLDShare")

if fserv is nothing then
msgbox "fserv is nothing“
endif

For Each share In fserv
If share.Path = Text1.Text Then
MsgBox share.Name + " " + share.Path
End If

Next share

我不知道你的Set fserv = GetObject("WinNT://pc14/LanmanServer")是否正确,也不知道你要得到什么对象,你如果知道对象包和对象名用CreateObject创建
pctommy 2002-07-18
  • 打赏
  • 举报
回复
我认为你应该把creatObject的工作放到循环里执行
rushing 2002-07-18
  • 打赏
  • 举报
回复
可以得到对象。
是共享的文件夹名称。
最后一个是$wwwroot

7,763

社区成员

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

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