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 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 "</p><p>而其中的每个编号对应的数字为:</p><p>共计有 gjazh 个对应的数值</p><p>gjcs(i)为“--”前面的内容, gjls(i))为后面的内容</p><p>1--20<br/>1A--20<br/>1B--20<br/>1C--20<br/>1D--20<br/>1E--20<br/>1F--20<br/>1G--20<br/>1H--20<br/>1J--20<br/>2--20<br/>2A--20<br/>2B--20<br/>2C--20<br/>2D--20<br/>2E--24<br/>2F--20<br/>2G--20<br/>2H--20<br/>2J--20<br/>2K--20<br/>2L--20<br/>3--20<br/>3A--20<br/>3B--24<br/>3C--20<br/>3D--20<br/>3E--20<br/>3F--24<br/>3G--20<br/>3H--20<br/>3J--20<br/>3K--20<br/>3L--24<br/>3M--24<br/>3N--20<br/>4--20<br/>4A--20<br/>4B--27<br/>4C--24<br/>4D--27<br/>4E--24<br/>4F--20<br/>5--30<br/>5A--33<br/>5B--33<br/>5C--30<br/>5D--24<br/>5E--27<br/>5F--24<br/>5G--24<br/>5H--20<br/>6--36<br/>6A--30<br/>6B--33<br/>6C--33<br/>6D--30<br/>6E--27<br/>7--42<br/>7A--36<br/>7B--39<br/>我咋用这个循环,确执行不了替换的呢?</p><p>For i = 1 To gjazh<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str13 = Replace(Strcc, gjcs(i), gjls(i))<br/>Next i</p><p></p>

xmok 发表于 2009-5-20 18:48:00

如果把 gjcs(i)和gjls(i)加上引号 ,那就无法执行循环了呀。

雪山飞狐_lzh 发表于 2009-5-20 23:08:00

<p>1--20?</p><p>这样替换可以么?会把所有的1都替换的</p><p></p><p>str13 = Strcc</p><p>For i = 1 To gjazh<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str13 = Replace(str13 , gjcs(i), gjls(i))<br/>Next i</p>

sailorcwx 发表于 2009-5-21 01:53:00

<p>以空格为分割符号用split函数分割成数组,然后遍历数组替换,然后再组合</p>
页: [1]
查看完整版本: [求助]这样的替换,咋样进行编程