?
Lv 5
? asked in 電腦與網際網路程式設計 · 1 decade ago

VB查詢程式

我在作一個程式兩個COMBOBOX,一個TEXTBOX第一個COMBOBOX點選版本(1.0,2.0,2.5…8.5),版本選完後第二個COMBOBOX內就有版本的分類,也不知道要怎樣說,假如第一個COMBOBOX點選1.0之後,在1.0內還有A,B,C三個任務,之後點選A或B或C,點選完後TEXTBOX就會出現內容我是以資料庫的形式下去查的,作了一些,碰到問題了,第二個COMBOBOX點選完後TEXTBOX跑不出來,所以上來發問原始碼!以下Private Sub Combo1_Click()If Dir(App.Path & "\\資料庫\\" & Combo1.Text & "\\", vbDirectory) = "" Then Exit Sub '如果檔案內沒有東西,就離開Combo2.Clear '清除Combo2裡面所有東西DoMyDirFile = DirIf MyDirFile <> ".." And MyDirFile <> "" Thena = Len(MyDirFile)If Right(MyDirFile, 4) = ".txt" ThenCombo2.AddItem Left(MyDirFile, a - 4)End IfEnd IfLoop Until MyDirFile = ""End SubPrivate Sub Combo2_Click()If Combo2.Text = "" Then Exit Sub '如果combo2沒東西就停止程式Open App.Path & "\\資料庫\\" & Combo1.Text & "\\" & Combo2.Text & ".txt" For Input As #1End SubPrivate Sub Form_Load()If Dir(App.Path & "\\資料庫\\", vbDirectory) = "" Then Exit SubDoMyDirFile = DirIf MyDirFile <> ".." And MyDirFile <> "" ThenCombo1.AddItem MyDirFileEnd IfLoop Until MyDirFile = ""End Sub麻煩各位了,有問題請發問我會補充!謝謝,,

Update:

原來我沒將檔案讀入,謝謝

想再請問,剛剛修改 讀檔好了

不過在TEXTBOX裡面的內容不會分段

請問要怎樣處裡

謝謝!

3 Answers

Rating
  • W.J.S.
    Lv 7
    1 decade ago
    Favorite Answer

    '你只有開檔,並無將檔案讀入TextBoxPrivate Sub Combo2_Click()    If Combo2.Text = "" Then Exit Sub '如果combo2沒東西就停止程式    Dim A() As Byte, S$        S = App.Path & "\資料庫\" & Combo1.Text & "\" & Combo2.Text & ".txt"    ReDim A(FileLen(S) - 1)    Open S For Binary As #1    Get #1, , A    Close #1    Text1 = StrConv(A, vbUnicode)End Sub

    2006-09-24 00:08:21 補充:

    Text1.MultiLine = True

    text1.ScrollBars=3

  • ?
    Lv 5
    1 decade ago

    我找不到0.0

  • 阿戊
    Lv 7
    1 decade ago

    要列檔案清單...

    VB內建的FileListBox粉好用~

    2006-09-23 23:40:58 補充:

    你的textbox要先設為多行顯示...

Still have questions? Get your answers by asking now.