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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find minimum and maximum 1

Status
Not open for further replies.

limeg95

Programmer
Oct 22, 2009
124
CA
hi!
i am trying to figure it out earlist starting time and latest finished time
here is the code. but i could not find out max and min
thanks in advance.
*****************************
If Right(JobName, 1) = "*" Then
For j = 1 To 16 '''

If Right(Trim(MyScreen.GetString(MyRw, 14)), 1) <> "p" Or _
Right(Trim(MyScreen.GetString(MyRw, 14)), 1) <> "z" Then '''
MyScreen.PutString "S", 6, 4
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE)
MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "STARTED - TIME" + "'")
MyScreen.SendKeys ("Enter")
MyRw = MyScreen.Row
myarray(j) = Trim(MyScreen.GetString(MyRw, 54, 6))
myarray2(j) = Trim(MyScreen.GetString(MyRw, 54, 6))
End If

Next j

MyStart = WorksheetFunction.Min(myarray2)

MyFinish = WorksheetFunction.Max(myarray)
Myjobloop = True
End If
'''''''''''''''''''''''''''''''''''''''''''''


 
for second variable i put it the same next screen ie j = 2
first screen and next screen
 



But j is STILL 1 for the second screen. I really do not understand that at all.
Code:
       MyScreen.SendKeys ("<pf3>") 'go to next j in screen
This is NOT TRUE!!! from that statement to the IF block.

Therefore, you should only have MyStart1 compared the the previous low value, NOT 1 AND 2!!!


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip thanks for helping out
so first value when we compare we need to initialize as 0
is it?
 

I do not know what that means.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
this is the code i have it now.
but how it comeout from this loop. still last it
For j = 1 To 14


' myStart1 = 0
g_HostSettleTimE1 = 75
MyScreen.SendKeys ("<Enter>")

MyScreen.Moveto 2, 15

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "STARTED - TIME=" + "'")
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyRw = MyScreen.Row


myStart1 = Trim(MyScreen.GetString(MyRw, 2, 5))

MyScreen.Moveto 2, 15
MyScreen.SendKeys ("<pf3>")



MyScreen.WaitHostQuiet (g_HostSettleTimE1)
' MyScreen.SendKeys ("<Enter>")


myStart2 = Trim(MyScreen.GetString(MyRw, 2, 5))
If myStart2 = myStart1 Then
myStart3 = myStart2
ElseIf myStart2 < myStart1 Then
myStart3 = myStart2
ElseIf myStart1 < myStart2 Then
myStart3 = myStart1
End If
' End If

Next j
 



PLEASE!

What is your question?

You need to be VERY explicit, and tell us what VALUES are in your variables and what VALUES are on the screen.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi Skip
it workes great. thanks a lot. there is a time issue also here it is fixed now
 
skip
this si my final code. it works. but is it still modify? please help me
from screen get all values and put only min statring time and max finished time in the cell.

----------------------------------------------------
For j = 1 To 14
prev = Trim(MyScreen.GetString(1, 19, 8))
MyScreen.Moveto 2, 15
MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "STARTED - TIME=" + "'")
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyRw = MyScreen.Row
myStart1 = Trim(MyScreen.GetString(MyRw, 2, 5))
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyScreen.Moveto 2, 15
MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "ENDED - TIME=" + "'")
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyRw = MyScreen.Row

myEnd1 = Trim(MyScreen.GetString(MyRw, 2, 5))

MyScre en.SendKeys ("<PF3>")

New1=Trim(MyScreen.GetString(1, 19, 8))
If New1 <> prev Then


MyScreen.WaitHostQuiet (g_HostSettleTimE1)

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "STARTED - TIME=" + "'")
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyRw = MyScreen.Row
myStart2 = Trim(MyScreen.GetString(MyRw, 2, 5))
If myStart1 = myStart2 Then
myStart1 = myStart3
ElseIf myStart1 < myStart2 Then
myStart1 = myStart3
ElseIf myStart2 < myStart1 Then
myStart2 = myStart3
End If
End If
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyScreen.Moveto 2, 15

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" '" + "ENDED - TIME=" + "'")
MyScreen.SendKeys ("<Enter>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)
MyRw = MyScreen.Row

myEnd2 = Trim(MyScreen.GetString(MyRw, 2, 5))
If myEnd = myEnd2 Then
myEnd = myEnd3
ElseIf myEnd > myEnd2 Then
myEnd = myEnd3
ElseIf myEnd < myEnd2 Then
myEnd2 = myEnd3
End If

' End If
End If

Next j
MyScreen.SendKeys ("<pf3>")
If Cells(i, "B").Value = "s" Then
Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol) = TimeSerial(Left(myStart3, 2), Right(myStart3, 2), 0)
ElseIf Cells(i, "B").Value = "f" Then
Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol + 1) = TimeSerial(Left(myEnd3, 2), Right(myEnd3, 2), 0)
End If

-----------------------------------------------------
 



Where is your i loop? the value of i never changes.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip
where do inlcude iloop already have one for next loop
 



Depends on your logic. What element are you finding the min/max for???

Looks like it might be, generally speaking...
Code:
Do i loop  (loop on [b]THAT element[/b] occurrence)

   do j loop

   loop
   
   write min/max to Excel
loop

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
i am looking for minstating time and max ending time
each screen find statand endtime
have 14 screens to find min and max into excel
 
skip
the above code i have it. could you help me where to include the loop
thanks a lot
 


I showed you in the pseudo code example above. It should be easy enought to understand.

What is it that you need to do i times to each of the 14 screens?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
i know you are very precious like me. coudl yuo show me for one. do i loop inside another loop i really lost again.
thanks for your great help
 
SORRY I MENTION PRECIOUS FOR ME INSTEAD FOR I PUT LIKE
THANKS FOR YOUR VALUBLE TIME.
 



Please explain to me exactly what you have to do i times to find the min & max in 14 screens.
[tt]
WhatValue
MinTime MaxTime
???????
[/tt]


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
thanks skip
minstarting time and maxing ending time from 14 screen
each screen take value starting time and ending time
out of 14 screens get min and max start and end time
 



If you only need to go thru the 14 screens ONE TIME, then replace i with 1.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top