按退出命令按钮,如何跳过控制代码?
在文本框的Valid中:IF not(thisform.text_khd.Value>0 and thisform.text_khd.Value<=5)
messagebox("请重新输入","系统提示")
thisform.text_khd.Value=0
Return .f.
ENDIF
用代码控制文本框输入内。
不输入内容,直接按退出命令按钮,也提示要求重新输入。
怎样才能跳过文本框输入控制代码,按退出命令按钮退出表单?
程序代码:
CLEAR ALL
CLEAR
oForm = CREATEOBJECT("C_Form")
WITH oForm
.Caption = "Test"
.AutoCenter = .T.
.Show
ENDWITH
READ EVENTS
CLEAR ALL
RETURN
DEFINE CLASS C_Form AS Form
ADD OBJECT Label1 AS Label WITH Caption = "数值1", Top = 5, Left = 5, Height = 25, Width = 60
ADD OBJECT Text1 AS TextBox WITH Value = 1, Height = 25, Width = 100
ADD OBJECT Label2 AS Label WITH Caption = "数值2", Value = 0, Top = 35, Left = 5, Height = 25, Width = 60
ADD OBJECT Text2 AS TextBox WITH Value = 0, Height = 25, Width = 100
ADD OBJECT cmdExit AS CommandButton WITH Caption = "退出[\<E]", Height = 25, Width = 60
PROCEDURE Text1.CheckValue()
WITH This
IF (.Value < 1) .OR. (.Value > 99)
WAIT ThisForm.Label1.Caption + "输入错误!" WINDOW NOWAIT TIMEOUT 2
.SetFocus
ENDIF
ENDWITH
ENDPROC
PROCEDURE Text2.GotFocus
ThisForm.Text1.CheckValue
ENDPROC
PROCEDURE cmdExit.Click
ThisForm.Release
ENDPROC
PROCEDURE Arrange
WITH ThisForm.Text1
.Top = ThisForm.Label1.Top
.Left = ThisForm.Label1.Left + ThisForm.Label1.Width + 5
ENDWITH
WITH ThisForm.Text2
.Top = ThisForm.Label2.Top
.Left = ThisForm.Label2.Left + ThisForm.Label2.Width + 5
ENDWITH
WITH ThisForm.cmdExit
.Top = ThisForm.Height - .Height - 5
.Left = 5
ENDWITH
ENDPROC
PROCEDURE Init
WITH ThisForm
.SetAll("FontBold", .T., "Label")
.SetAll("Alignment", 1, "Label")
.SetAll("SelectOnEntry", .T., "TextBox")
ENDWITH
ENDPROC
PROCEDURE Activate
ThisForm.Arrange
ENDPROC
PROCEDURE Resize
ThisForm.Arrange
ENDPROC
PROCEDURE Click
ThisForm.Text1.CheckValue
ENDPROC
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
ENDDEFINE
