多行的 print 不是可以配合 Open fn For Output Shared As #1 来写入文本文件中吗?如果我不想写入文件,而只是想写入内存呢?您也许会说,既然可以用 print ,那数据就已经在内存中了。没错,我用来print的数据已经从数据库中读出来了,但是,我需要修改,比如要在每个单元格数据两边加上<td></td>,然后再将修改后的数据写入内存
从窗体上获取print出来的内容?拷成一幅图回去加载到内存或用图形文字识别系统识别.
那你从内存中读出来不就行了,与print有什么关系?
我还是把代码贴出来吧这过程有两部分代码① Dim fn As String fn = App.Path & "\tem.txt" Open fn For Output Shared As #1 Print #1, "111" Print #1, "222" Print #1, "222" Close #1上面这个代码不是可以输出如下这样的数据吗? 111 222 333第②部分的代码是: Dim sHtml As String Dim hFile As Integer Dim Bytes() As Byte hFile = FreeFile() Open "C:\aaa.txt" For Binary Access Read Lock Write As #hFile ReDim Bytes(LOF(hFile) - 1) As Byte Get #hFile, 1, Bytes Close #hFile sHtml = StrConv(Bytes, vbUnicode) sHtml = Replace(sHtml, "$更改内容$", #1) hFile = FreeFile() Open "C:\bbb.txt" For Binary Access Write Lock Write As #hFile Put #hFile, 1, sHtml Close #hFile注意红色部分的“#1”,我本来要那样写的,结果没成功,不知大侠们能不能看懂我的意图,呵呵
要获得 111 222 333 只要读回来就行了: Dim fn As String Dim s() As Byte Dim s1 As String fn = App.Path & "\tem.txt" Open fn For Input As #1 s = InputB(EOF(1), #1) Close #1 s1 = StrConv(s, vbUnicode)
Clipboard.SetText?
Dim fn As String
fn = App.Path & "\tem.txt"
Open fn For Output Shared As #1
Print #1, "111"
Print #1, "222"
Print #1, "222"
Close #1上面这个代码不是可以输出如下这样的数据吗?
111
222
333第②部分的代码是:
Dim sHtml As String
Dim hFile As Integer
Dim Bytes() As Byte
hFile = FreeFile()
Open "C:\aaa.txt" For Binary Access Read Lock Write As #hFile
ReDim Bytes(LOF(hFile) - 1) As Byte
Get #hFile, 1, Bytes
Close #hFile
sHtml = StrConv(Bytes, vbUnicode)
sHtml = Replace(sHtml, "$更改内容$", #1)
hFile = FreeFile()
Open "C:\bbb.txt" For Binary Access Write Lock Write As #hFile
Put #hFile, 1, sHtml
Close #hFile注意红色部分的“#1”,我本来要那样写的,结果没成功,不知大侠们能不能看懂我的意图,呵呵
111
222
333
?
111
222
333
只要读回来就行了:
Dim fn As String
Dim s() As Byte
Dim s1 As String
fn = App.Path & "\tem.txt"
Open fn For Input As #1
s = InputB(EOF(1), #1)
Close #1
s1 = StrConv(s, vbUnicode)
1、把数据库中的数据用多行 print 读(写)出
2、将模板文件 aaa.txt 中的内容弄到内存中,并把其中的字符串“$更改内容$”替代为刚才读(写)出的数据
3、然后替代完成的数据再写入 bbb.txt请指教下,谢谢!