Option Explicit
Dim TxtLine() As String
Dim LineCount As Long
Private Sub TxtFile_Array(Path As String, TxtLine() As String)
Dim InputData As String
Dim TempInputData As String
Open Path For Input As #2
Do While Not EOF(2)
Line Input #2, InputData
TempInputData = Trim(InputData)
If TempInputData <> "" Then
ReDim Preserve TxtLine(LineCount) As String
TxtLine(LineCount) = TempInputData
LineCount = LineCount + 1
End If
Loop
Close #2
End Sub
Private Sub Form_Load()
Dim Path As String
Path = App.Path & "\test.txt"
TxtFile_Array Path, TxtLine
End Sub
Private Sub Timer1_Timer()
Static n As Long
n = n + 1
Clipboard.Clear
Clipboard.SetText TxtLine(n - 1)
Print Clipboard.GetText
SendKeys "^V"
If n >= LineCount Then n = 0
End Sub
参考资料:hyyly520 专门解答 MATLAB VB 基础问题
本回答被提问者采纳