關於vb split函數

請問我如果在text1裡輸入一串數字

每組數字用空格分開

用split 函數傳到num變數裡

num(0),num(1),num(2)......

請問要怎樣算出共有幾組數字??

3 Answers

Rating
  • 1 decade ago
    Favorite Answer

    在你用 split 傳到 num 變數後

    用 ubound 函數就可以取得該矩陣的維度 n

    n=ubound(num())

    2008-11-11 22:23:58 補充:

    例如說:

    Dim num() as String

    num = Split(Text1.Text,",")

    Text2.Text = Ubound(num)

     

    假設你在 Text1.Text 裡面輸入的是 1,2,3,4,5

    那你在 Text2.Text 會得到 4 (因為矩陣是從 0 開始)

    所以有 4+1 組數字

  • W.J.S.
    Lv 7
    1 decade ago

    andy大:請參考

    Dim s, i, j

    s = Split("1,2,3 4,5,6 7,8,9")

    ReDim a(UBound(s))

    For i = 0 To UBound(s)

    a(i) = Split(s(i), ",")

    Next

    For i = 0 To UBound(s)

    For j = 0 To UBound(a)

    Print a(i)(j),

    Next

    Print

    Next

  • 1 decade ago

    其實我很想問...split 能切成二維陣列嗎=.=?

Still have questions? Get your answers by asking now.