关于FSO问题!

喜洋洋和灰太狼 2009-11-04 11:00:03
 Private Sub AddList()
Dim i As Integer, s As String
s = LCase(Combo1.Text)
For i = 0 To Combo1.ListCount - 1
If LCase(Combo1.List(i)) = s Then _
Exit Sub
Next i
Combo1.AddItem Combo1.Text

'*写入到txt
Dim FSO As Object
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(App.Path & "/111.txt", ForWriting, True)
Dim y As Long
For y = 0 To Me.Combo1.ListCount - 1
FSO_File.WriteLine Me.Combo1.List(y)
Next
FSO_File.Close
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call AddList
End Sub

Private Sub Command1_Click()
'*txt导入
Dim FSO As Object
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(App.Path & "/111.txt", ForReading, False)
Do While Not FSO_File.AtEndOfStream
Me.Combo1.AddItem FSO_File.ReadLine
Loop
FSO_File.Close

End Sub






提示无效过程
...全文
131 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
谢谢 clear_zero老师 是我不认真弄错了!

Private Sub AddList()
Dim i As Integer, s As String
s = LCase(Combo1.Text)
For i = 0 To Combo1.ListCount - 1
If LCase(Combo1.List(i)) = s Then _
Exit Sub
Next i
Combo1.AddItem Combo1.Text

'*写入到txt
Dim FSO As Object
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(App.Path & "/111.txt", ForWriting, True)
Dim y As Long
For y = 0 To Me.Combo1.ListCount - 1
FSO_File.WriteLine Me.Combo1.List(y)
Next
FSO_File.Close

End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call AddList
End Sub

Private Sub Command1_Click()

Call AddList

End Sub


Private Sub Form_Load()
'*txt导入
Dim FSO As Object
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(App.Path & "/111.txt", ForReading, False)
Do While Not FSO_File.AtEndOfStream
Me.Combo1.AddItem FSO_File.ReadLine
Loop
FSO_File.Close


End Sub


以上是我修改后的!
clear_zero 2009-11-04
  • 打赏
  • 举报
回复
你添加了那个后,可以用
Dim fso As New FileSystemObject
Dim f As TextStream
Set f = fso.OpenTextFile("C:\a.txt", ForWriting, False)
代替
Dim FSO As Object
Dim FSO_File As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO_File = FSO.OpenTextFile(App.Path & "/111.txt", ForWriting, True)
clear_zero 2009-11-04
  • 打赏
  • 举报
回复
哪句提示?

你是否在 引用中添加了 Micorosoft Scription Runtime?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧