乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 74|回复: 6

删除不需要的支持路径

[复制链接]

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-10 12:20:30 | 显示全部楼层 |阅读模式
我编写了一些代码来删除不再需要的支持路径
我正在使用replace函数,但我知道我一定是做错了什么,因为它;“应该”;保留我当前的路径,只删除要删除的指定路径。出于某种原因,它也被从我当前的一些路径中删除
我知道它一定是我的Replace函数中的某个东西,但我不确定是什么
如果有人能帮我解决这个问题,我将不胜感激
谢谢Mark
  1. Sub DeleteFileSearchPaths()
  2. Dim CurrPaths, DeletePath(5), NewPaths As String
  3. Dim Preferences As AcadPreferences
  4. Dim dpcount As Integer
  5. Set Preferences = ThisDrawing.Application.Preferences
  6. CurrPaths = Preferences.Files.SupportPath
  7. 'Paths you want to delete
  8. DeletePath(0) = "I:\PATH\PATH"
  9. DeletePath(1) = "K:\PATH\PATH"
  10. DeletePath(2) = ""
  11. DeletePath(3) = ""
  12. DeletePath(4) = ""
  13.                  
  14.                  
  15.                  
  16. For dpcount = 0 To 4
  17. NewPaths = Replace(NewPaths, CurrPaths, DeletePath(5), 1, vbTextCompare)
  18. Next dpcount
  19. Preferences.Files.SupportPath = NewPaths
  20. End Sub


回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-10 13:30:31 | 显示全部楼层
NewPaths=Replace(NewPaths,CurrPaths,DeletePath(5),1,vbTextCompare)
1)在这里,您使用NewPaths作为搜索字符串,但它是空的,因此您将删除路径
电流路径现在是你的搜索字符串,错了
DeletePath(5)不是一个字符串,如果正确地将其暗显,则它是一个字符串数组
试试这个(你仍然需要得到正确的答案);DeletePath(5)作为字符串
NewPaths=Replace(CurrPaths,deleteppath(dpcount),&quot",1,vbTextCompare)
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-11 09:30:09 | 显示全部楼层

嘿,布莱,是的,我认为你是对的,我不知道;我不认为我的替换功能做得很对,这就是为什么我有这样的问题
是的,它本质上应该是当前路径-删除路径,我认为这是你建议的
另外,你是对的,我确实需要处理分号
我想这就是我需要的:
  1. NewPaths = Replace(CurrPaths &  ";" , DeletePath(dpcount), "", 1, vbTextCompare)
我们会看到的谢谢你Mark
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-11 13:01:58 | 显示全部楼层

布莱,你的建议不起作用:
  1. NewPaths = Replace(CurrPaths, DeletePath(dpcount), "", 1, vbTextCompare)
还有其他建议吗?我将不胜感激
同样,在这种情况下,我不't认为分号(是必要的。
标记
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-11 13:29:48 | 显示全部楼层

Duh,为什么不'我一开始没想过吗
现在它工作得很好,答案是:
  1. Sub DeleteFileSearchPaths()
  2. Dim CurrPaths, DeletePath(5)
  3. Dim Preferences As AcadPreferences
  4. Dim dpcount As Integer
  5. Set Preferences = ThisDrawing.Application.Preferences
  6. CurrPaths = Preferences.Files.SupportPath
  7. 'Paths you want to delete
  8. DeletePath(0) = "I:\Path\Path"
  9. DeletePath(1) = "K:\Path\Path"
  10. DeletePath(2) = ""
  11. DeletePath(3) = ""
  12. DeletePath(4) = ""
  13.                  
  14.                  
  15.                  
  16. For dpcount = 0 To 4
  17. CurrPaths = Replace(CurrPaths, DeletePath(dpcount), "", 1, vbTextCompare)
  18. Next dpcount
  19. Preferences.Files.SupportPath = CurrPaths
  20. End Sub
我们错过了显而易见的事情;Currpaths是用于保存当前支持路径的变量集
  1. CurrPaths = Preferences.Files.SupportPath
在这种情况下,当使用replace函数时,我们只想将currpaths(保存当前路径)替换为currpatys=currpathers-deletepaths,最终结果为:
  1. Preferences.Files.SupportPath = CurrPaths  (currpaths = currpaths - deletepaths)
我希望这有意义
无论如何,它正在按计划工作
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-11 20:58:31 | 显示全部楼层
做得好。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-11 22:41:10 | 显示全部楼层

好的,谢谢你;
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 19:12 , Processed in 0.527188 second(s), 67 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表