VB how to find the TXT file in the specified content (base)
Time:09-24
1 23 a785c4 liu yun 2016/5/3 14:14:57 2 C0370F10 Li Huateng 2016/5/3 14:14:59
This is the two rows of data in TXT file, Now you need to intercept "liu yun" the two key words,
Thank you all for the great god help!!!!!! (less than satisfactory answer search on the net)
CodePudding user response:
dim s1, s2 S1=split (s, VBRLF) "' s for the 2 rows you string S2=split (trim (s1 (0)), "") The debug. Print s2 (2)
CodePudding user response:
Do a simple example, for a while in to you,
CodePudding user response:
this is a text file this is to detect the name
Private Sub Command1_Click () Dim (AA) As String, MM As an Integer, B As String Text1. Text="" Open the App. The Path & amp; "\ AAAA. TXT" For Input As # 1 The Do While Not EOF (1) Input the # 1, B MM/MM + 1 'was record the total number of rows Loop Close # 1 Dynamic array ReDim AA (1 MM) To 'set the subscript Dim I As an Integer, As Integer X, Y As Integer Open the App. The Path & amp; "\ AAAA. TXT" For Input As # 1 The Do While Not EOF (1) I=I + 1 Input # 1, AA (I) 'row respectively read array Loop Close # 1 For I=1 To MM X=InStr (1, AA (I), "", 1) 'to get the position of the first space AA (I)=Right (AA (I), Len (AA) (I) - X) 'Right cut string Y=InStr (1, AA (I), "", 1) 'after clipping the first space position AA (I)=Left (AA (I), Y - 1) 'Left cut the string, get name Text1. Text=Text1. Text & amp; Trim (AA) (I) & amp; Space (2) 'in the text box output Next I End Sub
Array 1-8 got the name, you want to use that, all no problem,