Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

新手請教一個vb的問題

0 views
Skip to first unread message

尚未認證通過

unread,
Mar 10, 2003, 10:09:27 AM3/10/03
to
請問一下,如何在下拉式選單(combobox)中設定被選取的項目
可以在對應在清單(list)中show出外來的檔案?

ps. combobox的清單中已經設好qcmc和air這兩個選項

以下是我寫的程式,不知是哪裡出了問題??一直沒法在list中show出讀進來的檔

Option Explicit
Dim k As Integer
Dim TextLine, QCMC As String

Private Sub Combo1_Change()
If Combo1.Text = QCMC Then
'清除 List1 清單的內容
List1.Clear
Open "D:\QCMC.txt" For Input As #1
'設初始值
k = 0
' 執行迴圈直到檔尾為止
Do While Not EOF(1)
' 讀取一個列
Line Input #1, TextLine
'利用 K 值來計算筆數
k = k + 1
'新增項目到清單中
List1.AddItem TextLine
Loop
Close #1
End If
End Sub
--


另外小弟試過下面這種利用inputbox輸入值的方式作測試,它就可以show出我欲讀進
來的外來文字檔,不知上面的寫法問題是出在哪裡??
還請高手指點一二,感激不盡..^^

Option Explicit
'宣告全模組變數Dim k As Integer
Dim k As Integer
Dim temp As Double
Dim TextLine, QCMC As String

Private Sub Command1_Click()
temp = InputBox("請輸入欲查詢溫度", "°K", "100"): Text1.Text = temp
If temp = 50 Then
'清除 List1 清單的內容
List1.Clear
Open "D:\QCMC.txt" For Input As #1
'設初始值
k = 0
' 執行迴圈直到檔尾為止
Do While Not EOF(1)
' 讀取一個列
Line Input #1, TextLine
'利用 K 值來計算筆數
k = k + 1
'新增項目到清單中
List1.AddItem TextLine
Loop
Close #1
End If
End Sub

####################################################
# 幸福~不是每一天都有...錯過以後要等很久很久... # #
# 別讓你的快樂在我懷中變成泡沫.... #
# 至少~我們依然是朋友...如果我不適合握你的手... # #

[m [1;35m※ 來源:‧蛋捲廣場 bbs.tku.edu.tw‧[FROM: 61.64.153.144] [m

0 new messages