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
0
0
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
'''''''''''''''''''''''''''''''''''''''''''''


 




Is this EXACTLY what you see on your screen?
[tt]
sysoutid jobname jobix
s xxxxxa 'position row 6 press s position row 5
xxxxxb 'postion row 7
xxxxxc 'posiotn row 8
xxxxxd 'postion row 9
[/tt]
How many times do I have to ask you? My patience is wearing thin!!!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
apologies Skip
CA-View kmno -------------- Sysout list ------------------------------------
Command ===>
.Sel .Sysouti .Jobname .Jobid .ArchDate .Time .Loc . Lines.
.==> xxxxxxxx* 11/07/2009 *
xxxxxxaxxxxxxxa.xxxxxxa11/07/2009.20:03.TEMP.
xxxxxxxxb .xxxxxxxb xxxxxxb
xxxxxxxxc
xxxxxxxxd
xxxxxxxxe

********************************************************* Bottom of Data *************
 
CA-View kmno -------------- Sysout list ------------------------------------
Command ===>
.Sel .Sysout ID .Jobname .Jobid .ArchDate .Time .Loc . Lines. Pages.Xcode
.==> xxxxxxxx* * * 11/07/2009 * * * * *
xxxxxxxxa .xxxxxxxa.xxxxxxa
xxxxxxxxb .xxxxxxxb xxxxxxb
xxxxxxxxc
xxxxxxxxd
xxxxxxxxe
 
thanks for your all help, it works great.
 
skip
could you help me
does worksheetfuncitn.min(myarray) is not working it shows always 0
For j = 1 To 14
MyStart = Trim(MyScreen.GetString(MyRw, 2, 5))
myarray(j) = MyStart
MyFinish = Trim(MyScreen.GetString(MyRw, 2, 5))


myarray2(j) = MyFinish
next j
MyStart = WorksheetFunction.Min(myarray)

MyFinish = WorksheetFunction.Max(myarray2)
 



The MIN Spreadsheet Function does not work on arrays. It only works on Sheet Ranges

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
thanks i have start time and finish time as string
when i grab into excel for calculation purpose i need to change as time i need time exactly what it shows for example 20:20 after the format changed it shows different.
Cells(i, Mycol).NumberFormat = "h:mm"
hwo do i put it here either string or
 


example 20:20 after the format changed it shows different.

Different HOW?

Maybe something like 0.847222222?

If not try...
Code:
with Cells(i, Mycol)
   .value = .value * 1
   .NumberFormat = "h:mm"
end with


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
i put like this
but still it is not shwoing the same one

Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol).Value = MyStart
 

Please answer my first question...

Different HOW?


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
if it is string it shows 20.20
it is time it shows 4:48
 



That's because .20 of a day, in hours and minutes is 4:48.

faq68-5827.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


Check it out.

Enter 20.20 in a cell.

Select the cell and observe the value in the FORMULA BAR.

[tt]1/20/1900 4:48:00[/tt]

That's the 20th day since 1900,: January 20 1900.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
thanks a lot for your great informaiton solved
 

So if you want 20.20 to be interpreted as hours and minutes, you will need to PARSE into Hours and minutes and then CONVERT to a TimeValue...
Code:
dim a 

a = split(MyStart,".")

Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol).Value = TimeSerial(a(0),a(1),0)
if you're codeing in Excel VBA.

If you're coding in Extra...
Code:
Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol).Value = TimeSerial(Left(MyStart,2),Right(MyStart,2),0)



Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
how do i get max and min from screen time value in array form
20.01
18.02
13.03
14.05
15.06
i need max and min into cell
could you help me
i tried but its nothing worked out
 


What did you try?

Please post the code you tried.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip
the below code shows from 14 josb grab startign time and ending time take max and mix into excel thansk alot

For j = 1 To 14
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

MyStart = Trim(MyScreen.GetString(MyRw, 2, 5))
myarray(j) = MyStart

MyScreen.Moveto 2, 15

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

MyFinish = Trim(MyScreen.GetString(MyRw, 2, 5))
' MsgBox (MyFinish)

myarray2(j) = MyFinish
MyScreen.SendKeys ("<pf3>")
MyScreen.WaitHostQuiet (g_HostSettleTimE1)

MyStart = WorksheetFunction.Min(MyStart)

MyFinish = WorksheetFunction.Max(MyFinish)

Next j


Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol).Value = TimeSerial(Left(MyStart, 2), Right(MyStart, 2), 0)
Cells(i, Mycol).Value = WorksheetFunction.Min(MyStart)
MsgBox (Cells(i, Mycol).Value)

Cells(i, Mycol).NumberFormat = "h:mm"
Cells(i, Mycol).Value = MyFinish
' MsgBox (Cells(i, Mycol).Value)


 


Code:
    g_HostSettleTimE1 = 75
    For j = 1 To 14
        MyScreen.SendKeys ("<Enter>")
        MyScreen.Moveto 2, 15
        
        MyScreen.SendKeys ("F")
        MyScreen.SendKeys (" '" + "STARTED - TIME=" + "'")
        MyScreen.SendKeys ("<Enter>")
        MyScreen.WaitHostQuiet (g_HostSettleTimE1)
        MyRw = MyScreen.Row
        
        myarray(j) = Trim(MyScreen.GetString(MyRw, 2, 5))
'[s]
        myarray(j) = MyStart
'[/s]
        MyScreen.Moveto 2, 15
        
        MyScreen.SendKeys ("F")
        MyScreen.SendKeys (" '" + "ENDED - TIME=" + "'")
        MyScreen.SendKeys ("<Enter>")
        MyScreen.WaitHostQuiet (g_HostSettleTimE1)
        MyRw = MyScreen.Row
        
        myarray2(j) = Trim(MyScreen.GetString(MyRw, 2, 5))
        ' MsgBox (MyFinish)
'[s]
        myarray2(j) = MyFinish
'[/s]
        MyScreen.SendKeys ("<pf3>")
        MyScreen.WaitHostQuiet (g_HostSettleTimE1)
'[s]
        MyStart = WorksheetFunction.Min(MyStart)
        MyFinish = WorksheetFunction.Max(MyFinish)
'[/s]
    Next j
 
    For j = 0 To UBound(myarray)
        Cells(i, mycol).NumberFormat = "h:mm"
        Cells(i, mycol).Value = TimeSerial(Left(myarray(j), 2), Right(myarray(j), 2), 0)
        
        Cells(i, mycol + 1).NumberFormat = "h:mm"
        Cells(i, mycol + 1).Value = TimeSerial(Left(myarray2(j), 2), Right(myarray2(j), 2), 0)
    Next
    MsgBox (WorksheetFunction.Min(Columns(mycol)))
    MsgBox (WorksheetFunction.Min(Columns(mycol + 1)))

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


except, I cannot see how your i counter is incrimenting. THAT must change!

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