Home > Software engineering >  Using VB to find out a maximum and minimum value
Using VB to find out a maximum and minimum value

Time:11-01

The serial number number
1 531
2 545
3 321
4 211
5 121
6 to 10
7 to 10
8 and 9
9 110
10 1285
11 213
12 and 22
13 of 19
14 of 18
15 12
16 1
17 52
18 66
19 73
Every period of maximum minimum value should be the following
The serial number sequence number
1 531
2 545
6 to 10
8 and 9
10 1285
16 1
19 73

CodePudding user response:

Under the pot first contact my Chinese teacher, asked him to look at...

CodePudding user response:

Dim b As Boolean 'True means inc and false means dec
Dim a (1 To 19) As an Integer
Dim As Integer I
A (1)=531
A (2)=545
.
A (19)=73
Print 1, a (1)
If a (2) & gt; A (1) b=False Else b=True
For I=2 To 19
If (a (I) & gt; A (I - 1)) & lt;> B Then Print I, a (I)
Next I

CodePudding user response:

Modify the
For I=2 To 19
If (a (I) & gt; A (I - 1)) & lt;> B Then Print I, (I) a: b=Not (b)
Next I

CodePudding user response:

reference 1st floor yiguangqiang88 response:
pot under the first contact my Chinese teacher, asked him to take a look at...

agree

CodePudding user response:

 
Option Explicit

Private Sub Command1_Click ()
Dim intMax As an Integer, intMin As an Integer, n As Integer
Dim strLine As String, strItems () As String

IntMax=0
IntMin=32767

"C: \ 3. TXT" Open For Input As # 1
Do Until EOF (1)
The Line Input # 1, strLine
StrItems=Split (strLine, "")

If UBound (strItems)=1 Then
N=Val (strItems (1))
If n & gt; IntMax Then
IntMax=n
The Debug. Print strLine
The Else
If n & lt; IntMin Then
IntMin=n
The Debug. Print strLine
End the If
End the If
End the If
Loop
Close # 1
End Sub

Results:
531
 12 545 
3 321
4 211
5 121
6 to 10
8 and 9
10 1285
16 1

CodePudding user response:

reference 1st floor yiguangqiang88 response:
pot under the first contact my Chinese teacher, asked him to take a look at...


The original poster is to output the maximum and minimum values,

CodePudding user response:

All these data into the array, and then find an order with respect to OK

CodePudding user response:

Demand isn't this meaning, the original poster is when detailed data increase, the moment of maximum and minimum values:
 
Data number maximum minimum
1 531 531
2 545 531
3 545 321
4, 545, 211
5 545 122
6 545 10
7 545 10
8 545 9
9 545 9
10 1285
11 1285 1

When the maximum minimum value changes, print change value,

CodePudding user response:

Is such judgment will be subject to first determine the Numbers below is the rise or fall, is the high rise to find the number, such as 531 to 545 is 2 to 1 2 was 545 vertices, pre-approved lowest and highest point, among the abandoned, such as falling from 2, 545 to 8, 9, keep high and low, because of no. 2, 545 is the highest point of the retained only keep low, 8, 9 among the abandoned, and so on... Law to find litres of the maximum and minimum, down the maximum and minimum

CodePudding user response:

All wrong, somebody else is looking for a reversal point.
First set a rise or fall of marked Flag=1 (0) up or down
Read data in sequence, the current data comparing with the previous data.
If not (flag Xor number (Now) & gt; Number (Now - 1)), then the
The Read Number (Now + 1)
The else
Print the Number (Now)
End the if

CodePudding user response:


The result is the same,

CodePudding user response:


Or, is your actual application requirements into mathematical logic,

CodePudding user response:

 
'this code is the main.
If (Flag Xor CDbl (strItems (1)) & gt; Then CDbl (BakNumber)))
Me. Print BakNumber
Flag=Not Flag
The Else
BakNumber=strItems (1)
End the If

CodePudding user response:

 
'will you changed the code, so that the output of the results are not consistent with the result of your, this should be LZ want.

Option Explicit

Private Sub Command1_Click ()
Dim intMax As an Integer, intMin As an Integer, n As Integer
Dim strLine As String, strItems () As String

IntMax=0
IntMin=32767
Dim Flag As Boolean
Flag=True
Dim BakNumber As Double
BakNumber=1
"C: \ 3. TXT" Open For Input As # 1
The Line Input # 1, strLine
StrItems=Split (strLine, "")
Me. Print strItems (1)
Do Until EOF (1)
The Line Input # 1, strLine
StrItems=Split (strLine, "")
If (Flag Xor CDbl (strItems (1)) & gt; Then CDbl (BakNumber)))
Me. Print BakNumber
Flag=Not Flag
The Else
BakNumber=strItems (1)
End the If
Loop
Me. Print strItems (1)
Close # 1
End Sub

CodePudding user response:

refer to 6th floor of123 response:
Quote: refer to 1st floor yiguangqiang88 response:

Under the pot first contact my Chinese teacher, asked him to look at...


The original poster is to output the maximum and minimum values,
admire understanding ability, to be honest, the 1/f, still can't really understand this point...

CodePudding user response:

VB6 is?

CodePudding user response:

1 531
2 545
3 321
4 211
5 121
6 to 10
8 and 9
10 1285
16 1
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related