Re: [VB6 ] 問一個有點笨的問題

看板Visual_Basic作者 (㊣糜不有初,鮮克有終)時間17年前 (2009/03/05 00:58), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/6 (看更多)
※ 引述《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! ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ http://www.youtube.com/user/JamesBondXD▄▄ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.217.155.159

03/07 09:51, , 1F
以上是不可用的,因為vb6不支援陣列索引的字串型態
03/07 09:51, 1F

03/07 12:27, , 2F
我又洨了 X(
03/07 12:27, 2F
※ 編輯: MOONRAKER 來自: 61.217.153.216 (03/07 14:43)
文章代碼(AID): #19hhCoGj (Visual_Basic)
討論串 (同標題文章)
文章代碼(AID): #19hhCoGj (Visual_Basic)