Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Time
Message
From
24/11/2003 19:02:10
 
 
General information
Forum:
ASP.NET
Category:
Visual FoxPro Toolkit for .NET
Title:
Re: Time
Miscellaneous
Thread ID:
00851981
Message ID:
00853128
Views:
20
>I am a beginner in Foxpro, I would like to know how could I view into spinner a range of hours in the 12 clock. Then input them into the table like 24 clock type.

Hi Jess, welcome to Visual FoxPro. I'm the product manager of VFP at Microsoft. What version of VFP are you using? I assume you want to have an entry system on a form for 12-hour format and then store it as 24 hour format. I'm not sure of the exact data type you are storing the time, but for fun I just created a sample VFP form to show you an example of what you are wanting to do. I converted the form to PRG source code below using the Class Browser. If you want me to send you the SCX/SCT form files, email me at klevy@microsoft.com.


PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


**************************************************
*-- Form: form1 (c:\temp\x.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 11/24/03 03:59:10 PM
*
DEFINE CLASS form1 AS form


Height = 184
Width = 248
DoCreate = .T.
AutoCenter = .T.
Caption = "12 Hour to 24 Hour"
Name = "Form1"


ADD OBJECT spnhour AS spinner WITH ;
Height = 24, ;
InputMask = "##", ;
Left = 60, ;
SpinnerHighValue = 12.00, ;
SpinnerLowValue = 1.00, ;
TabIndex = 2, ;
Top = 48, ;
Width = 48, ;
Value = 12, ;
Name = "spnHour"


ADD OBJECT optampm AS optiongroup WITH ;
ButtonCount = 2, ;
BorderStyle = 0, ;
Value = 1, ;
Height = 36, ;
Left = 158, ;
Top = 42, ;
Width = 36, ;
TabIndex = 5, ;
Name = "optAMPM", ;
Option1.Caption = "AM", ;
Option1.Value = 1, ;
Option1.Height = 17, ;
Option1.Left = 0, ;
Option1.Top = 0, ;
Option1.Width = 34, ;
Option1.AutoSize = .T., ;
Option1.Name = "Option1", ;
Option2.Caption = "PM", ;
Option2.Height = 17, ;
Option2.Left = 0, ;
Option2.Top = 14, ;
Option2.Width = 35, ;
Option2.AutoSize = .T., ;
Option2.Name = "Option2"


ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Hour:", ;
Height = 17, ;
Left = 60, ;
Top = 32, ;
Width = 32, ;
TabIndex = 1, ;
Name = "Label1"


ADD OBJECT command1 AS commandbutton WITH ;
Top = 96, ;
Left = 96, ;
Height = 27, ;
Width = 72, ;
Caption = "Get Time", ;
TabIndex = 6, ;
Name = "Command1"


ADD OBJECT spnminute AS spinner WITH ;
Height = 24, ;
InputMask = "##", ;
Left = 108, ;
SpinnerHighValue = 59.00, ;
SpinnerLowValue = 0.00, ;
TabIndex = 4, ;
Top = 48, ;
Width = 48, ;
Value = 0, ;
Name = "spnMinute"


ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
Caption = "Minute:", ;
Height = 17, ;
Left = 108, ;
Top = 32, ;
Width = 41, ;
TabIndex = 3, ;
Name = "Label2"


ADD OBJECT label3 AS label WITH ;
AutoSize = .T., ;
Caption = "Time:", ;
Height = 17, ;
Left = 24, ;
Top = 52, ;
Width = 33, ;
TabIndex = 1, ;
Name = "Label3"


PROCEDURE spnhour.Valid
IF NOT BETWEEN(this.Value,1,12)
RETURN .F.
ENDIF
ENDPROC


PROCEDURE command1.Click
LOCAL lcHour,lcMinute
lcHour=TRANSFORM(MOD(MOD(thisform.spnHour.Value,12)+IIF(thisform.optAMPM.Value=2,12,0),24))
lcHour=IIF(LEN(lcHour)=2,lcHour,"0"+lcHour)
lcMinute=TRANSFORM(thisform.spnMinute.Value)
lcMinute=IIF(LEN(lcMinute)=2,lcMinute,"0"+lcMinute)
MESSAGEBOX("24 Time: "+lcHour+":"+lcMinute)
ENDPROC


PROCEDURE spnminute.Valid
IF NOT BETWEEN(this.Value,1,60)
RETURN .F.
ENDIF
ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Previous
Reply
Map
View

Click here to load this message in the networking platform