我在 Windows 系统中有一个很大的文本文件,逐行以 chr(13) 结尾。我想将文本存储在 Access MDB 文件的备注字段中,该字段的最大大小限制为 64K。
文本文件包含 unicode 字符。
如何使用 vb6 行输入法将文本拆分为多个文件?或者除了编写程序之外,还有其他更好的方法吗?
文本示例:
1 00:00:01,960 --> 00:00:04,880 哦哦,前方一迎就上
2 00:00:04,880 --> 00:00:07,600 去。我都讲,拉球摩擦是需要的
3 00:00:07,600 --> 00:00:10,480 顶,没有顶,它不是一个
4 00:00:10,480 --> 00:00:13,280 简单的往上的动作,它需要侧面
5 00:00:13,280 --> 00:00:16,240 往前顶,找到球的时候给一个小动
Public Sub splitFile()
Dim i, t1, t2, c1, c2, k As Long
Dim TextLine, OutLine
Dim thisfile
Dim partCount
thisfile = "speechByParts.txt"
partCount = 0
OutLine = ""
Open thisfile For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
Debug.Print TextLine
OutLine = OutLine & TextLine & Chr(13)
If Len(OutLine) > 60000 Then
partCount = partCount + 1
WriteFile "speechByParts" & partCount & ".txt", OutLine
OutLine = ""
End If
Loop
If OutLine > "" Then
partCount = partCount + 1
WriteFile "speechByParts" & partCount & ".txt", OutLine
End If
Close #1 ' Close file
End Sub
读写包含 Unicode 的文本文件有两种常用方法:使用文件系统对象 (FSO) 或使用 ActiveX 数据对象 (ADO)。以下是一个使用 ADO 的示例。为简单起见,代码将输入文件中的每一行写入一个新文件。您需要设置对“Microsoft ActiveX 数据对象 2.8 库”的引用。