VB6如何提取CSV文件首行第12个字段内容(即L1单元格)
各位老师:VB6如何提取FR.CSV文件首行第12个字段内容(即L1单元格),L1单元格由公式构成,想提取计算后的结果到TEXT1文本框中
谢谢!
2023-04-22 15:31
。
2023-04-22 17:57
程序代码:Private Sub Command1_Click()
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim csvText As String
Dim csvArray() As String
Dim l1Text As String
' 打开文件并读取内容到字符串变量
Set ts = fso.OpenTextFile("FR.csv", ForReading)
csvText = ts.ReadAll
' 关闭文件
ts.Close
' 将字符串按行分割为数组
csvArray = Split(csvText, vbCrLf)
' 提取第一行的数据
Dim row1() As String
row1 = Split(csvArray(0), ",")
' 提取第12个字段(即L1单元格)的内容
l1Text = row1(11)
' 将提取的结果显示在TEXT1文本框中
Text1.Text = l1Text
End Sub
2023-04-24 18:57