我唔識 Split function.,vb問題[好急!!!] [10點]

2008-01-04 2:26 am
我唔識 Split function. 如下


s = "I am a boy"
a = Split(s, " ") ' a 是一個列陣

For i = 0 To UBound(a)
v = v & a(i) & vbCrLf
Next
' Display v


a = Split(s, " ") 如果我有兩個condition,
咁應該點寫??


我想將

I am a boy. I am a boy. I am a boy.
I love cat. I love cat.

變成

I
am
a
boy.
I
am
a
boy.
I
am
a
boy.

I
love
cat.
I
love
cat.


應該點樣做????? 請各位高手教下我

回答 (2)

2008-01-09 10:51 pm
✔ 最佳答案
s = "I am a boy. I am a boy. I am a boy." & vbCrLf & "I love cat. I love cat."
a = Split(Replace(s, vbCrLf, " "), " ") ' a 是一個陣列

For i = 0 To UBound(a)
v = v & a(i) & vbCrLf
' Display v
MsgBox v
Next
2008-01-04 2:53 am
係唔係想咁:
a = Split(Replace(s, vbCrLf, " "), " ")
Replace function 內 (s, vbCrLf, " ") 係兩個空格


收錄日期: 2021-04-27 15:01:25
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080103000051KK02419

檢視 Wayback Machine 備份