Home > Software engineering >  (vb) great spirit to guide the water ratio, vb for a column in a TXT file data, the minimum value
(vb) great spirit to guide the water ratio, vb for a column in a TXT file data, the minimum value

Time:09-23

For a column in a TXT file data, the smallest value of TXT file for a.t xt, for example, the data is as follows:
1, 2, 3, 4
5,6,7,8
2, 5-tetrafluorobenzoic
,,,,,,
Learning the primary level, guidance,
Such as minimum values for the third column, write the code, thank you very much,

CodePudding user response:

Simple example, the file path, you is best when commissioning according to the full path to the actual writing,
Without exception handling, so your file, each row should have at least three, and the third number can't be a number of "illegal",
If necessary yourself plus (but you don't know how to add ),
 Private Sub Command1_Click () 
Dim strText As String
Dim w As Long, m As Long

Open "a.t xt" For Input As # 1
The Line Input # 1, strText
W=Split (strText, ", ") (2)
The Do While Not EOF (1)
The Line Input # 1, strText
If (strText="") Then Exit the Do
M=Split (strText, ", ") (2)
If (m & lt; W) Then w=m
Loop
The Close
MsgBox "the minimum is:" & amp; W, 64
End Sub

CodePudding user response:

 Dim strLine As String, strTmp () As String, strMin As String 

Open "a.t xt" For Input As # 1
The Line Input # 1, strLine
StrTmp=Split (strLine, ", ")
StrMin=strTmp (2)

Do Until EOF (1)
The Line Input # 1, strLine
StrTmp=Split (strLine, ", ")
If strMin & gt; StrTmp (2) Then strMin=strTmp (2)
Loop

Close # 1

MsgBox strMin

CodePudding user response:

If Val (strMin) & gt; Val (strTmp (2)) Then strMin=strTmp (2)
can support more than one digit

CodePudding user response:

Read line by line, according to the comma split into an array,
Then remove them to specify the number of columns, endures a variable, each with a variable's value is size, small update variables,
  • Related