- Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
$Form1 = GUICreate("งงๆอยู่", 237, 293, 403, 140)
$Input1 = GUICtrlCreateInput("15000", 8, 8, 217, 21,$ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE)
$Input2 = GUICtrlCreateInput("", 8, 32, 217, 21 ,$ES_NUMBER)
$Button1 = GUICtrlCreateButton("Button1", 8, 56, 217, 25)
$Group1 = GUICtrlCreateGroup("Group1", 8, 88, 217, 193)
$Label1 = GUICtrlCreateLabel("99", 48, 168, 132, 90)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 48, 400, 0, "Palatino Linotype")
$Button2 = GUICtrlCreateButton("Button2", 48, 112, 129, 33)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
$in1=GUICtrlRead($Input1) ;ไม่ใช้สูตรนี้มันอ่านได้ 2
$in2=GUICtrlRead($Input2) ;ไม่ใช้สูตรนี้มันอ่านได้ 3
If $in1 < $in2 Then
MsgBox(64,"ข้อความ","จำนวนแรกมีน้อยเกินไป.")
MsgBox(64,$in1,$in2)
GUICtrlSetData($Input2,"")
Else
GUICtrlSetData($Input1,GUICtrlRead($Input1) - $in2)
GUICtrlSetState($Input2,$GUI_DISABLE)
GUICtrlSetState($Button1,$GUI_DISABLE)
GUICtrlSetState($Button2,$GUI_ENABLE)
EndIf
Case $Button2
GUICtrlSetState($Label1,$GUI_SHOW)
_PSSIX()
GUICtrlSetdata($Input1,Random(1,100,1))
GUICtrlSetState($Input2,$GUI_ENABLE)
GUICtrlSetState($Button1,$GUI_ENABLE)
GUICtrlSetState($Button2,$GUI_DISABLE)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _PSSIX()
if $Label1 = 99 Then
MsgBox(0,"ยังงงๆอยู่","โดยเฉพราะตรงที่เปลี่ยบเทียบค่า อินพุต 1 กะ 2")
EndIf
EndFunc
คือผมตั้ง Input1 ไว้ที่ 15000 ส่วน Input2 ให้ใส่ได้เอง
แต่ห้ามเกินค่าของ Input1
ผมลองใส่ input2 เป็น 1999999 มันก็เตือนถูก
ผมใส่ input2 เป็น 20 มันก็ยังเตือนว่า input1 น้อยเกินไป
เลยลองหลายที จนถึง 999 ก็ไม่ได้
มันให้ 1000 ขึ้นไป
ช่วยไขให้กระจ่างหน่อยครับ ขอบคูณครับ