明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1225|回复: 3

[求助]这样的替换,咋样进行编程

[复制链接]
发表于 2009-5-20 18:46:00 | 显示全部楼层 |阅读模式

strcc="2D 3N 2D 4E 2D 4E 2D 4E 2D 4D 2C 4D 2A 5C 2B 39 3N 3D 3N 3D 4F 3D 4F 3C 4F 3A 4C 3A 4C 3 4C 3A 5 5F 3D 3N 3D 4F 3D 4F 3D 4F 3D 4F 3D 5G 3C 5F 3A 5D 6A 3B 3N 3D 4F 3D 4F 3D 5H 3D 5G 3C 5F 3A 6E 3 6E 7A 3B 3N 3D 4F 3D 4F 3D 5G 3C 5G 3A 6E 3A 6E 3 6D 7A 1D 3D 3D 3D 3C 3A 3A 3 1D 2L 2D 2L 2D 2L 2D 2L 2D 2L 2D 2L 2D 2L 3L 1D 3N 1D 2L 1D 2L 1D 2L 2D 3M 2D 4D 2C 4D 6B 1D 3N 1D 2L 1D 2L 1D 3M 1C 4C 1B 5C 1A 5C 39 1D 3N 1D 2L 1D 2L 1C 3M 1B 4B 1B 6C 1A 6B 7 1D 1D 1D 1C 1B 1A 1 4A 2K 3K 2K 3K 1J 3K 2K 1J 1J 3K 1J 1J 1J 3J 1J 1J 2J 3J 1J 1J 2J 3J 1H 1H 3J 3H 1G 3F 4 3K 2K 3K 2K 3K 1J 2K 1J 3K 1J 2K 1J 2K 1J 1J 1J 2K 1H 1H 1J 2K 1H 1H 2K 3K 1H 1H 2K 3J 1G 2E 3H 3H 2J 1J 1J 3K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1H 2J 2H 1H 1H 2H 2H 1G 1F 3G 3E 1F 1J 1J 3K 1J 1J 1J 2K 1J 1J 1J 1J 1J 1J 1J 1J 1J 1H 1H 1G 1H 1H 2H 1G 1G 1G 1G 2H 1G 1F 2G 2F 1E 1J 1J 2K 2K 1J 1J 1J 2K 1J 1J 1J 1J 1J 1J 1J 1J 1H 1H 1G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 3D 4F 3D 4F 3D 5H 3D 5G 3C 5F 3A 6E 3 6E 3B 3N 3D 4F 3D 4F 3D 5G 3C 5G 3A 6E 3A 6E 3 6D 1D 2L 2D 2L 2D 2L 2D 2L 2D 2L 2D 2L 2D 2L 3L 1D 3N 1D 2L 1D 2L 1D 2L 2D 3M 2D 4D 2C 4D 5A 1D 3N 1D 2L 1D 2L 1D 3M 1C 4C 1B 5C 1A 5B 39 1D 3N 1D 2L 1D 2L 1C 3M 1B 4B 1B 6C 1A 6B 7 1D 1D 1D 1C 1B 1A 1 4A 2K 3K 2K 3K 1J 3K 1J 2K 1J 3K 1J 1J 1J 3J 1J 1J 2J 3J 1J 1J 2J 3J 1H 1H 3J 3H 1G 3F 4 3K 1J 3K 1J 3K 1J 2K 1J 3K 1J 2K 1J 2K 1J 1J 1J 2K 1H 1H 1J 2K 1H 1H 2K 3K 1H 1H 2K 3J 1G 2G 3H 3H 2J 1J 1J 3K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1H 2J 2H 1H 1H 2H 2H 1G 1F 3G 3E 1F 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 2K 1J 1J 1J 1J 1J 1H 1H 1G 1H 1H 2H 1G 1G 1G 1G 2H 1G 1F 2G 2F 1E 1J 1J 2K 2K 1J 1J 1J 1J 1J 1J 1J 1J 1J 1J 1J 1J 1H 1H 1G 1G 1G 1G 1G 1G 1F 1F 1F 1F 1F 1F 1E 1E 3N 2L 3M 4E 5E 6C 6 7 7 6 6C 5E 4E 2L 2L 3N 2 2 2D 2B 1 2 2 1 2B 2D "

而其中的每个编号对应的数字为:

共计有 gjazh 个对应的数值

gjcs(i)为“--”前面的内容, gjls(i))为后面的内容

1--20
1A--20
1B--20
1C--20
1D--20
1E--20
1F--20
1G--20
1H--20
1J--20
2--20
2A--20
2B--20
2C--20
2D--20
2E--24
2F--20
2G--20
2H--20
2J--20
2K--20
2L--20
3--20
3A--20
3B--24
3C--20
3D--20
3E--20
3F--24
3G--20
3H--20
3J--20
3K--20
3L--24
3M--24
3N--20
4--20
4A--20
4B--27
4C--24
4D--27
4E--24
4F--20
5--30
5A--33
5B--33
5C--30
5D--24
5E--27
5F--24
5G--24
5H--20
6--36
6A--30
6B--33
6C--33
6D--30
6E--27
7--42
7A--36
7B--39
我咋用这个循环,确执行不了替换的呢?

For i = 1 To gjazh
        str13 = Replace(Strcc, gjcs(i), gjls(i))
Next i

 楼主| 发表于 2009-5-20 18:48:00 | 显示全部楼层
如果把 gjcs(i)和gjls(i)加上引号 ,那就无法执行循环了呀。
发表于 2009-5-20 23:08:00 | 显示全部楼层

1--20?

这样替换可以么?会把所有的1都替换的

str13 = Strcc

For i = 1 To gjazh
        str13 = Replace(str13 , gjcs(i), gjls(i))
Next i

发表于 2009-5-21 01:53:00 | 显示全部楼层

以空格为分割符号用split函数分割成数组,然后遍历数组替换,然后再组合

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 03:47 , Processed in 0.150172 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表