stanley1974 发表于 2009-2-25 15:21:15

如何填回值至GUI Input裡面

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <string.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("電阻分壓計算", 482, 313, 307, 168)
$Input1= GUICtrlCreateInput("", 184, 104, 65, 21)
$Input2 = GUICtrlCreateInput("", 184, 144, 65, 21)
$Input3 = GUICtrlCreateInput("", 184, 184, 65, 21)
$Input4 = GUICtrlCreateInput("", 184, 224, 65, 21)
$Button1 = GUICtrlCreateButton("Cal", 320, 152, 89, 57, 0)
$Button2 = GUICtrlCreateButton("Exit", 320, 220, 89, 57, 0)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xC0DCC0)
GUICtrlSetCursor (-1, 0)

$Label1 = GUICtrlCreateLabel("Vin:", 136, 104, 35, 24) ;Vin
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Vout:", 128, 144, 47, 24) ;vout
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("R1", 136, 184, 25, 24);R1
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("R2", 136, 224, 25, 24) ;R2
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("電阻分壓計算", 168, 56, 88, 17)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Dim $Vin=1,$Vout=1,$R1=1,$R2=1,$val=0
      
      
      
While 1
$nMsg = GUIGetMsg()

Switch $nMsg
      Case $GUI_EVENT_CLOSE
                MsgBox(0, "", "Dialog was closed")
                Exit

      Case $Button1
                ;Hex = _StringToHex($Input1)
               
             $Vin=GUICtrlRead($Input1)
               $R1=GUICtrlRead($Input3)
               $R2=GUICtrlRead($Input4)
               $Vout=($vin*$R2)/($R1+$R2)
               ;=$Vout
                MsgBox(0, "Default button clicked","Vout=" & $Vout)
               
                ;MsgBox(0, "Default button clicked","Hex=" & $Hex)
      Case $Button2
                Exit
EndSwitch
WEnd
請問各位大大:
如何填回值至GUI Input裡面呢?
感謝。

[ 本帖最后由 stanley1974 于 2009-2-25 16:56 编辑 ]

cnsnc 发表于 2009-2-25 15:26:06

GUICtrlSetData($Input2,$Vout)

stanley1974 发表于 2009-2-25 16:55:37

感謝cnsnc 大大的幫忙。已經可以了。謝謝。
页: [1]
查看完整版本: 如何填回值至GUI Input裡面