溢流染色机工艺流程:File1.ListIndex的值为什么总是-1

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 07:55:43
我最近几天喜欢上了VB,以前上学时没编过,现在工作了又拾起来了。昨天开始到现在编了100多K的一个文章管理软件,把我喜欢的文章用数据库连接起来(以前用ASP做了一个,正好用它的数据库)。
这里出了一点问题:
Private Sub OKButton_Click()
Dim num As Integer
Dim i As Integer
Dim filename As String
num = File1.ListCount
MsgBox "listcount =" & num
Unload Me
i = File1.ListIndex
MsgBox "File1.ListIndex=" & i
If File1.Selected(i-1) = True Then
filename = File1.Path + "\" + File1.list(i-1)
MsgBox "选中了" & i & "号文件"
End If
Form1.Text2.Text = filename
MsgBox filename
End Sub

上面还有个FileListBox控件,点OK_Button后将其值传给Form1的Text2来进行选择数据库的操作。
可是File1.ListIndex的值总是-1,明明选中了一个.MDB数据库文件,ListCount的值也返回了1。
不明白,高手给看看。

前面有个unload me把控件卸掉了肯定是-1了