作者MOONRAKER (㊣糜不有初,鲜克有终)
看板Visual_Basic
标题Re: [VB6 ] 问一个有点笨的问题
时间Thu Mar 5 00:58:23 2009
※ 引述《yellissckk (疯狂甜不辣)》之铭言:
: 请问各位唷
: 每次要用到A-Z的时候
: 总是要从头打一遍
: 例如
: replace(replace(string,"A","#"),"B","#").....
: 假设我要把所有字母都取代成那个符号
: 这样就要打好大一串
: 请问有比较简便的方式吗??
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
对不起,经指正,以下的程式是错的,
所以请看後面一篇使用regex的就好,这篇别看了。 X( MOONRAKER
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
function alpha2hash(s as string) as string
dim s2 as string
dim i as integer
s2 = ""
for i = 1 to len(s)
if s(i) >= "A" and s(i) <= "Z" then
s2 = s2 + "#"
else
s2 = s2 + s(i)
end if
next i
alpha2hash = s2
end function
不用五分钟。
你嫌长的话,以下函数做的是一样的事。
function a2hash(s as string) as string
for i = 1 to len(s)
if s(i)>="A" and s(i)<="Z" then s2=s2+"#" else s2=s2+s(i)
next i
a2hash = s2
end function
--
BATCH 03 : 买张床 - 切达大侠 - 伐木人之歌 -
http://tinyurl.com/3zpyx5
[B4准备中]: 讴歌金钱(7/02) - 单车超人(7/23) -
http://tinyurl.com/66v6vq
[ 番外篇 ]: 包租婆也有过当罗莉的时候(7/17) -
http://tinyurl.com/6j4ale
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
■ 蒙帝派松正体中文计画 ■ Spam-a-lot and enjoy the pythonesque delight!
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/user/JamesBondXD▄▄
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.217.155.159
1F:推 fumizuki:以上是不可用的,因为vb6不支援阵列索引的字串型态 03/07 09:51
2F:→ MOONRAKER:我又洨了 X( 03/07 12:27
※ 编辑: MOONRAKER 来自: 61.217.153.216 (03/07 14:43)