以下是小弟的码,请各位前辈多多的指教哦
;~ 编写一个程序,要求用户输入小时数和分钟数。
;~ 在MAIN()函数中,传递给一个void函数,后者以下面这样的格式显示这两个值:
;~ Enter the Number of hours : 9
;~ Enter the Number of minutes : 28
;~ Time : 9:28
$Form1 = GUICreate("练习",200,150,-1,-1)
GUICtrlCreateLabel("小时数:",5,2)
GUICtrlCreateLabel("分钟数:",5,22)
$input = GUICtrlCreateInput("",65,2,80,15)
$input1 = GUICtrlCreateInput("",65,22,80,15)
$button = GUICtrlCreateButton("确定",60,40,30,20)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $button
main()
EndSwitch
wend
Func main()
$Rinput = GUICtrlRead($input)
$Rinput1 = GUICtrlRead($input1)
shizhong($Rinput,$Rinput1)
EndFunc
Func shizhong($Rinput,$Rinput1)
If $Rinput > 23 Or $Rinput < 0 Or $Rinput1 > 59 Or $Rinput1 < 0 Then
MsgBox(0,'提示','请输入正确的小值和分钟值')
ElseIf 1 = StringIsInt($Rinput) And 1 = StringIsInt($Rinput1) Then
MsgBox(0,'你输入的时间','Enter the Number of hours : '&$Rinput _
&@CRLF&'Enter the Number of minutes : '&$Rinput1 _
&@CRLF&'Time : '&$Rinput&':'&$Rinput1)
Else
MsgBox(0,'提示','请输入整数')
EndIf
EndFunc
|