程序运行后用 Open openfilename For Input As #1
打开一个txt的文件可以,但是不退出程序,再打开txt文件就不行了。
打开一个txt的文件可以,但是不退出程序,再打开txt文件就不行了。
解决方案 »
- 求一个SQL语句
- 使用Recordset.Save('', adPersistXML)方法将纪录集保存成xml,如何每次只存当前记录
- 哪位大哥有PowerTCP FTP Tool的安装软件和注册机?
- 如何在图片控件中显示数据库中的图片?
- 在VB里访问不了SQL SERVER服务器?
- 怎样创建控件数组?
- VB6.0企业版不能识别access2000,access2002!?
- 关于excel里vba的版本问题
- 如何判断Recordset是否将表锁定??
- 给100分:请问为什么我删除了一条记录,然后让ADO控件refresh,为什么表单上还有删除的记录?
- 如何判断一个文件夹是否存在?
- [请教]关于VB画图
没有关闭文件
再加上
Close #1
试试看,行不行
Close #1
Close #FileNum 关闭他
.
.
.
Close #1
同理,打开某个文件就应该用完之后关掉它
Line Input #1, linestr
Text1.Text = linestr
Close #1
For i = 1 To 115
Open "C:\1.txt" For Output As #1
Print #1, listlinks.list(i)
Next
Close #1End Sub为什么我不能把listlinks 列表里list 输出到 文本谁帮个忙。谢谢
Open "C:\1.txt" For Output As #1For i = 1 To 115
Print #1, listlinks.list(i)
Next
Close #1End Sub
除非 open ... for input Lock Read Write As #...
Open "C:\1.txt" For Output As #1
Print #1, listlinks.list(i)
Next
Close #1
这段程序进行的操作和你想要实现的目标不匹配
这个文本文件最后只能写一个数据,每次都被更新了
如果将 关键字 Output改成 append 就可以实现了
如下:Open "C:\1.txt" For Append As #1
文件被关闭了,然后再打开应该是没有什么错误会发生的,除非你在程序运行之前已经
在windows下将文本文件打开了。
:-))
Dim iDoc As IHTMLDocument2
Dim el As Object
Dim total As String
Dim fso As New FileSystemObject
Dim sTxt As TextStream
Private Const conSwNormal = 1
Private Sub Command1_Click()
Command2.Enabled = False
Text1.Text = Replace(Text1.Text, " ", "%20")
flag = False
Dim urllist As String
urllist = "http://www1.baidu.com/baidu?word=intitle:" & Text1.Text & "&cl=3"
web.Navigate urllist
Do While Not flag
DoEvents
DoEvents
DoEvents
DoEvents
Loop
getList
Launch
End Sub
Private Sub getList()
Dim obj As IHTMLElement
Dim oo As Object
Dim tbl As HTMLBodySet iDoc = web.DocumentSet oo = iDoc.All.tags("FONT")For scan = 0 To oo.length - 1
If InStr(oo.Item(scan).innerText, "href") > 0 Then
posA = oo.Item(scan).sourceIndex
Exit For
End If
NextFor g = posA To iDoc.All.length - 1
If iDoc.All.Item(g).tagName = "BODY" Then
posB = iDoc.All.Item(g).sourceIndex
Exit For
End If
NextSet oo = iDoc.All.tags("BODY")For g = 0 To oo.length - 1
If oo.Item(g).sourceIndex = posB Then
Set tbl = oo.Item(g)
Exit For
End If
NextFor l = 0 To tbl.All.length - 1
If tbl.All.Item(l).tagName = "A" Then
Set el = tbl.All.Item(l)
strcontent = strcontent & "<a href='" & el.href & "'>" & el.innerText & "</a><br>" & vbCrLf
End If
Next
Set sTxt = fso.CreateTextFile(App.Path & "\jobResult.htm")
header = "<html><head></head><body>" & vbCrLf
total = header & strcontent & "</body></html>"
sTxt.write header & strcontent & "</body></html>"
sTxt.Close
Set fso = NothingEnd SubPrivate Sub Launch()
web.Document.write (total & "<br>Ce fichier est disponible sous le nom jobResult.htm dans le r閜ertoire de l'application")
Command2.Enabled = True
End SubPrivate Sub Command2_Click()
web.Navigate App.Path & "\jobResult.htm"End SubPrivate Sub Form_Resize()
web.Width = Me.Width - 151
If (Me.Width - 151 - Command2.Width - 10 > 0) Then Command2.Left = Me.Width - 151 - Command2.Width - 10
If Me.Width - 3500 > 0 Then Text1.Width = Me.Width - 3500
End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1_Click
End SubPrivate Sub web_DocumentComplete(ByVal pDisp As Object, URL As Variant)
flag = True
End Sub
哪个朋友帮忙看看这个代码-返回的是整理后的搜索结果!可我想把不要的祛除!而且能不断的继续下面的页码!谢谢