Access VB script 問題

想問一下怎樣可將一個 multi line 既 text box, 一行一行咁放入指定既 text box.

既係:
Line1 -->  text box 1
Line2 -->  text box 2
Line3 -->  text box 3

Dim myString  

' comma separated string value assigned to the variable
myString = "str1,str2,str3,str4,str5"

' variable to store the result of Split function
Dim myArray

' split function with delimiter parameter as comma ","
myArray = Split(myString,",")


明唔明? 將最後一行 "," 轉 Chr(23) <-- 好似係 23 就 ok

[ 本帖最後由 tunster 於 2008-10-25 10:50 編輯 ]

TOP

謝謝你的回覆, 雖然我明白個 flow, 但係當應用係 textbox 就唔得. 或者 upload 個 prototype result 大家研究一下

[ 本帖最後由 hacker1202 於 2008-10-25 12:11 編輯 ]
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

Textbox 咪又係 String. 你咪讀個 boxname.Text 出0黎咪得囉

TOP

可能自己唔記得點 read Array, split 出來的東西似乎是 null

TOP

俾0的 code 睇下

TOP

終於完成到第一行 , 但係想問點樣可以係個 for loop 裡面 i = 1 to <TotalNumberOfLines>, 同將個 [Text1] 可以好似 [Text(i)].Text 咁去做

    Dim MyString
    Dim MyArray
   
    MyString = [Text1].Text
    MyArray = Split(MyString, Chr(13) & Chr(10))
    For i = 1 To 3
        [Text1]= MyArray(i)
    Next i

[ 本帖最後由 hacker1202 於 2008-10-25 12:53 編輯 ]

TOP

寫得不太好, 不知可不可以....
text0 是 input textbox
text1, text2, text3 是 line1,line2, line3的textbox
=====================================
    Dim strText() As String
    If Not IsNull(Text0.Value) Then
        strText = Split(Text0.Value, vbCrLf)
        If UBound(strText()) > 0 Then
            Select Case UBound(strText())
                Case 1
                    Text1.Value = strText(0)
                    Text2.Value = strText(1)
                    Text3.Value = ""
                Case 2
                    Text1.Value = strText(0)
                    Text2.Value = strText(1)
                    Text3.Value = strText(2)
                Case Else
                    Text1.Value = strText(0)
                    Text2.Value = strText(1)
                    Text3.Value = strText(2)
            End Select
        Else
            Text1.Value = Text0.Value
            Text2.Value = ""
            Text3.Value = ""
        End If
    End If

TOP

我找過 access vba help 內有一個 example 叫 CountOfLines, 但係照佢指示放入 module 內都行唔到. 不過因為 text box 數量唔多, 但之後仲要行 trimming, 唯有現在多打幾行

TOP

原帖由 hacker1202 於 2008-10-25 12:49 發表
終於完成到第一行 , 但係想問點樣可以係個 for loop 裡面 i = 1 to , 同將個 [Text1] 可以好似 [Text(i)].Text 咁去做

    Dim MyString
    Dim MyArray
   
    MyString = [Text1].Text
    MyArray = Sp ...


MyArray.Count = Number of items in the array
用 .Count

至於 text1.text 0個個你要用 array 將0的 textbox object 先指晒入去...再用 array set 就得.

TOP