7,785
社区成员




Private Sub Get_Line_Column_Data(Byval LineNum As Long, Byval ColumnNum As Long)
Dim strLine As String, strCol() As String, i As Long
i = 1
Open "D:\111.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strLine
If i = LineNum Then
strCol = Split(strLine, Space(1))
If ColumnNum <= Ubound(strCol) + 1
Text1 = strCol(ColumnNum - 1)
Else
Text1 = "Bad Column Number"
End If
End If
i = i + 1
Loop
If i < LineNum Then Text1 = "Bad Line Number"
Close #1
End Sub
Option Explicit
Dim r1 As RegExp, m1 As MatchCollection
Dim r2 As RegExp, m2 As MatchCollection
Private Sub Command1_Click()
Set m2 = r2.Execute(m1.Item(2)) '第三行
Text2 = m2.Item(3) '第四列
End Sub
Private Sub Form_Load()
Set r1 = New RegExp
With r1
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "^.+$"
End With
Set m1 = r1.Execute(Text1)
Set r2 = New RegExp
With r2
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "\S+\b"
End With
End Sub
Private Sub Form_Load()
Dim lngFn As Long, strT As String
lngFn = FreeFile
Open "d:\1.txt" For Binary As #lngFn
strT = Space(LOF(lngFn))
Get #1, , strT
Close #lngFn
Dim sArr() As String
sArr = Split(strT, vbCrLf)
MsgBox Split(sArr(2), " ")(3) ''第3行第4列值
End Sub