Home > Software engineering >  VB how to find the TXT file in the specified content (base)
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,

CodePudding user response:

The
reference 3 floor u013249970 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

1-8 array got the name, you want to use that, all no problem,


The
reference 3 floor u013249970 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

1-8 array got the name, you want to use that, all no problem,


Is that if I find the "liu yun", I will obtain the corresponding database, which is used if then statements, do not need to output text

CodePudding user response:

There are rules will press the space into an array,

CodePudding user response:

If there is no law, I think we can regard it as a long string of a string, so how to distinguish? For example:
Because the Chinese characters in vb is definitely of two significant byte & amp; ???? , and standard symbols, Numbers and letters are & amp; 00?? ,
So as long as using copymemory individually to determine whether a character memory than & amp; 00 ff,
Of course, if you know the Chinese characters which area is more accurate,

CodePudding user response:

"Interception" what meaning be? To modify the file?

CodePudding user response:

InStr (" 123333 liu yun 12324 ", "liu yun)"
  • Related