我試圖檢索海盜的Penzance少將歌(在這裏找到:http://www.naic.edu/~gibson/poems/gilbert1.html)字符串「少將」之前和之後的5個字符。我試圖找到一個比我有更好的方式來做到這一點,並試圖找出爲什麼它不循環。任何想法將不勝感激!VBscript和InStr函數
l1 =INSTR(l2, string, "Major-General")
l2 = 5
l3 = 1
vcount=0
if vcount <5 then
l1 =INSTR(l3, string, "Major-General")
vcount = vcount +1
word = mid(string, l1-5, l2)
word1 = mid(string, l1+13, l2)
l3 = l3+l1
response.write "<br>" & "5 before: " & word & "<br>" & "5 after: " & word1
end if
_「試圖找出它爲什麼不循環」_好,因爲實際上我沒有看到該代碼中的任何循環... – 2014-09-25 16:36:31
不夠公平。這樣做比使用mid()更好嗎?它看起來笨重。 – 2014-09-25 16:55:25