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

我唔識 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 Answers

Rating
  • 1 decade ago
    Best Answer

    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

  • 1 decade ago

    係唔係想咁:

    a = Split(Replace(s, vbCrLf, " "), " ")

    Replace function 內 (s, vbCrLf, " ") 係兩個空格

Still have questions? Get your answers by asking now.