+ -
当前位置:首页 → 问答吧 → 读取txt文件为组合框赋值

读取txt文件为组合框赋值

时间:2011-08-05

来源:互联网

请各位老大教教我怎么读取txt文件为组合框的列表赋值
mypath="d:\123.txt"

[ 本帖最后由 psh1102 于 2011-8-5 18:47 编辑 ]

作者: psh1102   发布时间: 2011-08-05

我复制一个现成的公式。LoadTxt  "d:\123.txt" , ComboBox1

Public Function LoadTxt(StrPath As String, LstControls As Object) ' 将文本加载到ListBox 或者ComboBox中
Dim str As String
Open StrPath For Input As #1
If Dir(StrPath, vbDirectory) = "" Then
Exit Function
End If
Do While Not EOF(1)
Line Input #1, str
With LstControls
.AddItem str
  End With
Loop
Close #1
End Function

作者: 帮一帮   发布时间: 2011-08-05

相关阅读 更多