如何用VB读取文件中具体行和具体列的特定数值
3个回答
展开全部
’自己修改
Private Sub Command1_Click()
Dim i As Long, row As Long, col As Long, arr
Open "c:\123.txt" For Input As #1
row = 5: col = 3 '设置行号和列号
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
If row + 1 <= UBound(arr) Then
If col <= Len(arr(row)) Then MsgBox "行号:" & row & ",列号:" & col & "=" & Mid(arr(row - 1), col, 1)
End If
End Sub
Private Sub Command1_Click()
Dim i As Long, row As Long, col As Long, arr
Open "c:\123.txt" For Input As #1
row = 5: col = 3 '设置行号和列号
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
If row + 1 <= UBound(arr) Then
If col <= Len(arr(row)) Then MsgBox "行号:" & row & ",列号:" & col & "=" & Mid(arr(row - 1), col, 1)
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询