'AutoConvert Time Setting 'Created By: Jon Michael Bevar 'http://www.freewebs.com/onclicksoftware '10/17/2002 'This will allow one to Auto enter the current computers time or bybass it 'to enter you own time setting. This can be retro fitted to other applications 'that would want to have a option to either auto enter the current time or enter 'there own time in. $Include "Rapidq.inc" $TypeCheck on Declare Sub AutoTime(Key as word, Shift as Integer, Sender as QEdit) Declare Sub TSAMClick Declare Sub TSPMClick Declare Sub AutoTimeConvert Declare Sub ConvertTime Dim ConvertTimeH as Integer Dim ConvertTimeH$ as String Dim ConvertTimeM$ as String Dim TimeShift as String Dim TSA as String Dim TSP as String TSA = "A.M." TSP = "P.M." CREATE Form AS QFORM Caption = "Auto Time" Width = 320 Height = 240 Center CREATE Label1 AS QLABEL Caption = "Time:" Left = 80 Top = 24 END CREATE CREATE GetTime AS QEDIT Text = "" Left = 80 Top = 40 Width = 60 InputMask = "##:## ####" OnKeyPress = AutoTime END CREATE Create Label5 as QLabel Caption = "Press Enter to enter current Time" Left = 70 Top = 90 END CREATE CREATE Button2 AS QBUTTON Caption = "Ok" Left = 80 Top = 144 TabOrder = 2 Onclick = ConvertTime END CREATE CREATE ConvertedTime AS QEDIT Text = "" Left = 80 Top = 112 Width = 100 TabOrder = 3 END CREATE CREATE TSAM AS QRADIOBUTTON Caption = "A.M." Left = 176 Top = 40 Width = 41 TabOrder = 4 OnClick = TSAMClick END CREATE CREATE TSPM AS QRADIOBUTTON Caption = "P.M." Left = 224 Top = 40 Width = 49 TabOrder = 5 Onclick = TSPMClick END CREATE END CREATE 'This will enter the time using the computers TIME$ setting by simply pressing on the 'ENTER key. This routine is needed as the TIME$ function is set to military 24 hour scale. Sub AutoTime(Key as word, Shift as Integer, Sender as QEdit) Select Case Key Case 13 ConvertTimeH$ = Mid$(Time$,1,2) If ConvertTimeH$ < "12" Then TimeShift = TSA End If If ConvertTimeH$ = "12" Then TimeShift = TSP End If If ConvertTimeH$ = "00" Then ConvertTimeH$ = "12" TimeShift = TSA End If 'Note: The following lines of code are there if you have your users input a 24 Hour Time Scale, 'this is the error checking for entering a number larger then 24 for the HOURS. 'If ConvertTimeH$ is > "24" Then ' ShowMessage("Incorrect H Time Entry. Please try again.") ' Exit Sub 'End If If ConvertTimeH$ => "13" Then ConvertTimeH = (Val(ConvertTimeH$)-12) ConvertTimeH$ = Str$(ConvertTimeH) If ConvertTimeH$ => "1" or ConvertTimeH$ =< "9" Then ConvertTimeH$ = "0" + ConvertTimeH$ End If TimeShift = TSP End If ConvertTimeM$ = Mid$(Time$,4,2) 'Note: The following lines of code are there if you have your users input a 24 Hour Time Scale, 'this is the error checking for entering a number larger then 59 for the MINUTES. 'If ConvertTimeM$ > "59" Then ' ShowMessage("Incorrect M Time Entry. Please try again.") ' Exit Sub 'End If GetTime.text = ConvertTimeH$ + ":" + ConvertTimeM$ + " " + TimeShift End Select End Sub 'If this RadioButton was clicked then enter "A.M." as the TimeShift. Sub TSAMClick TimeShift = TSA End sub 'If this RadioButton was clicked then enter "P.M." as the TimeShift. Sub TSPMClick TimeShift = TSP End Sub 'This is the Time Converting Code to convert Military Time(24Hour) to Normal Time (AM/PM) Sub ConvertTime ConvertTimeH$ = Mid$(GetTime.text,1,2) If ConvertTimeH$ < "01" Then ShowMessage("Incorrect Hour Setting. Please try again.") Exit Sub End If If ConvertTimeH$ > "12" Then ShowMessage("Incorrect Hour Setting. Please try again.") Exit Sub End If ConvertTimeM$ = Mid$(GetTime.text,4,2) If ConvertTimeM$ > "59" Then ShowMessage("Incorrect Minute Setting. Please try again.") Exit Sub End If If ConvertTimeM$ = " " Then ConvertTimeM$ = "00" End If If TimeShift = "" Then ShowMessage("Please Select either A.M. or P.M. TimeShift.") Exit Sub End If GetTime.text = ConvertTimeH$ + ":" + ConvertTimeM$ + " " + TimeShift End Sub Form.ShowModal