Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

much calmer now need help with this code 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
i would like to output "p" and "p1" in a descending order
"p" or "p1"is not in an array or is being taken from one. it is from a formula.
I would greatly appreciate the help


CLS
'Read data and calculate best total'
INPUT "Please enter an INPUT VOLTAGE ", vin
INPUT "Please enter an OUTPUT VOLTAGE ", vout
INPUT "Please enter an INPUT IMPEDANCE ", z

DIM percoferror AS DOUBLE
DIM current AS DOUBLE
DIM vr1 AS DOUBLE
DIM vres2 AS DOUBLE
DIM diffvoltage AS DOUBLE
DIM seed#(256)
DIM res#(256)
REM
I = 1
READ seed#(I)
WHILE seed#(I) <> 0
I = I + 1
READ seed#(I)
WEND

datastrlength = I - 1
arraylength = 0
FOR J = 0 TO 6
FOR I = 1 TO datastrlength
FOR h = 1 TO datastrlength + 1
arraylength = arraylength + 1
res = (10 ^ J) * seed#(I)
res2 = (10 ^ 4) * seed#(h)
zt = res + res2
current = vin / zt
vr1 = current * res
vres2 = vin - vr1
diffvoltage = vout - vres2
p = (diffvoltage / vout) * 100

IF zt >= z THEN
IF p >= 0 THEN
IF p <= 7 THEN
FOR t = 1 TO 100000
NEXT t
PRINT p

END IF
END IF
END IF
NEXT h
NEXT I
NEXT J



datastrlength = I - 1
arraylength = 0
FOR J = 0 TO 6
FOR I = 1 TO datastrlength
FOR h = 1 TO datastrlength + 1
arraylength = arraylength + 1
res = (10 ^ J) * seed#(I)
res2 = (10 ^ 5) * seed#(h)
zt = res + res2
current = vin / zt
vr1 = current * res
vres2 = vin - vr1
diffvoltage = vout - vres2
p1 = (diffvoltage / vout) * 100

IF zt >= z THEN
IF p1 >= 0 THEN
IF p1 <= 7 THEN
FOR t = 1 TO 100000
NEXT t
PRINT p1
END IF
END IF
END IF
NEXT h
NEXT I
NEXT J

DATA 1.0,1.2,1.5,1.8,2.2,2.7,3.3,3.9,4.3,4.7
DATA 5.1,5.6,6.2,6.8,7.5,8.2,9.1,0
END

 
I only did the first part for you. I hope that is what you were after.

Code:
Cls
'Read data and calculate best total'
INPUT &quot;Please enter an INPUT VOLTAGE    &quot;, vin
INPUT &quot;Please enter an OUTPUT VOLTAGE   &quot;, vout
INPUT &quot;Please enter an INPUT IMPEDANCE  &quot;, z

Dim percoferror  As Double
Dim current      As Double
Dim vr1          As Double
Dim vres2        As Double
Dim diffvoltage  As Double
Dim seed#(256)
Dim res#(256)

Rem
i = 1
READ seed#(i)
While seed#(i) <> 0
i = i + 1
READ seed#(i)
Wend

datastrlength = i - 1
ARRAYLENGTH = 0
Dim PSORT#(7 * datastrlength * (datastrlength + 1))
For J = 0 To 6
For i = 1 To datastrlength
For h = 1 To datastrlength + 1
ARRAYLENGTH = ARRAYLENGTH + 1
res = (10 ^ J) * seed#(i)
res2 = (10 ^ 4) * seed#(h)
zt = res + res2
current = vin / zt
vr1 = current * res
vres2 = vin - vr1
diffvoltage = vout - vres2
P = (diffvoltage / vout) * 100

If zt >= z Then
If P >= 0 Then
If P <= 7 Then
'put in array
PSORT#(ARRAYLENGTH) = P
'
End If
End If
End If
Next h
Next i
Next J
'
'sort the PSORT# array
NUMBEROFELEMENTS = ARRAYLENGTH
FLAG = 1
While FLAG > 0
NUMBEROFELEMENTS = NUMBEROFELEMENTS - 1
FLAG = 0
For x = 1 To NUMBEROFELEMENTS
If PSORT#(x) <= PSORT#(x + 1) Then GoTo 100
SWAP PSORT#(x), PSORT#(x + 1)
FLAG = 1
100 Next x
Wend
'PRINT THE LIST
For SEARCH = ARRAYLENGTH To 1 Step -1
If PSORT#(SEARCH) = 0 Then GoTo 200 'don't print anything if a 0
Print PSORT#(SEARCH)
For x = 1 To 32000        'slow it down a bit
For y = 1 To 40: Next y
Next x
200 Next SEARCH

Stop
' you can repeat code for this section
x = 0

datastrlength = i - 1
ARRAYLENGTH = 0
For J = 0 To 6
For i = 1 To datastrlength
For h = 1 To datastrlength + 1
ARRAYLENGTH = ARRAYLENGTH + 1
res = (10 ^ J) * seed#(i)
res2 = (10 ^ 5) * seed#(h)
zt = res + res2
current = vin / zt
vr1 = current * res
vres2 = vin - vr1
diffvoltage = vout - vres2
 p1 = (diffvoltage / vout) * 100

If zt >= z Then
If p1 >= 0 Then
If p1 <= 7 Then
'put in array

End If
End If
End If
Next h
Next i
Next J


Data 1#, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.3, 4.7
Data 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1, 0
End

[\code]:-)  
 
David Paulson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top