|
D:/数据/a.txt 有数据 35 8,竖排,格式为:
35
8
Sub Test()
Dim strA As String, strB As String
Dim lngI As Long
Dim lngCol As Long
'**************
'从a.txt文件中读取数据的代码如何写?
'我这里直接赋值了
strA = "35": strB = "8"
'*****************
For lngI = 1 To 4095
lngCol = 2 + 4 * (lngI - 1)
Sheet1.Cells(1, lngCol) = strA
Sheet1.Cells(1, lngCol + 1) = strB
Next
End Sub
- Sub test()
- Dim arr(1)
- Open "D:/数据/a.txt" For Input As #1
- Do While Not EOF(1)
- Line Input #1, st
- arr(k) = st
- k = k + 1
- Loop
- Close #1
- For n = 2 To 4095 * 4 Step 4
- Range(Cells(1, n), Cells(1, n + 1)) = arr
- Next
- End Sub
复制代码
|
|