English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

題目是降子:
1.VB讀檔 test.txt 內容為\"I Love You.\"
2.將\"I Love You.\"轉成ASCII
3.轉完存回陣列,再存成output.txt
---------------------------------------------------
我先拉一個text1當顯示的地方用
---------------------------------------------------
用Command1當「結束」:
Private Sub Command1_Click()
End
End Sub
-----------------------------------------------
用Command2當「讀檔」:
Private Sub Command2_Click()
Dim buff1 As String
Open App.Path & \"\\test.txt\" For Input As #1
Line Input #1, buff1
Text1.Text = buff1
Close #1
End Sub
----------------------------------------------------
我想拉Command3當「轉成ASCII」:
(這裡我就不會寫了...要用到陣列....可以教我嗎?
上網查半天找不到我要的...)
-----------------------------------------------------
Command4當「輸出到output.txt」:
(目前只會寫到這,不知對不對)
Open App.Path & \"\\output.txt\" For Output As #1
-----------------------------------------------------

大概是降子,麻煩大家了,謝謝

2006-03-15 19:05:44 · 2 個解答 · 發問者 阿雷好了 2 in 電腦與網際網路 程式設計

先謝謝回答的人, 可是....
有沒有再簡單一點的笨寫法?

2006-03-15 20:12:33 · update #1

2 個解答

Dim A() As StringPrivate Sub Command2_Click()Dim buff1 As StringOpen App.Path & "\test.txt" For Input As #1Do Until EOF(1)   Line Input #1, buff1   Text1.Text = buff1 & vbCrLfLoopClose #1Text1 = Left(Text1, Len(Text1) - 1)End SubPrivate Sub Command3_Click()Dim A() As String, I As Integer, X As IntegerFor I = 0 To Len(Text1)    ReDim Preserve A(X)    A(X) = Asc(Mid$(Text1, I, 1))    X = X + 1NextEnd SubPrivate Sub Command4_Click()Dim I As IntegerOpen App.Path & "\output.txt" For Output As #1For I = 0 To UBound(A)    If Val(A(I)) <> vbCrLf Then       Print #1, A(I)    Else       Print #1, vbCrLf    End IfNextClose #1End Sub

2006-03-16 11:48:32 補充:
參考同樣的一題吧^^http://tw.knowledge.yahoo.com/question/?qid=1306031115125

2006-03-15 04:04:25 · answer #1 · answered by W.J.S. 7 · 0 0

1.你可以先在"一般/宣告"中宣告Dim ary()
2.然後先判斷test.txt內容有幾個字元(你可以先轉存到一個Strin變數中,例如S$)
3.再重新宣告ary(註) 註:test.txt內容的字元數目

2006-03-15 19:21:53 · answer #2 · answered by 天使 4 · 0 0

fedest.com, questions and answers