zhenglei 发表于 2011-1-8 21:21:06

读取配置文件数值进行比对为什么4都大于300????

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

Dim $cfg=@ScriptDir&"\1.txt"
$k=IniRead($cfg,"set","数值","")
MsgBox(64,"123",$k)
$Form1 = GUICreate("Form1", 224, 109, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 193, 21)
$Input2 = GUICtrlCreateInput("Input2", 16, 40, 193, 21)
$Button1 = GUICtrlCreateButton("Button1", 104, 64, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1;;;;;;; 数字4,5,6,7,8,9 等数字 它计算的结果小于$K怎样才可以正确比对??
                        If GUICtrlRead($Input1)<=$k Then GUICtrlSetData($Input2,GUICtrlRead($Input1))
        EndSwitch
WEnd
1.TXT内容

数值=300

_ddqs. 发表于 2011-1-8 21:39:42


If GUICtrlRead($Input1) <= Number($k) Then GUICtrlSetData($Input2, GUICtrlRead($Input1))

水木子 发表于 2011-1-8 21:40:13

Dim $cfg = @ScriptDir & "\1.txt"
$k = Number(IniRead($cfg, "set", "数值", ""))
MsgBox(64, "123", $k)
$Form1 = GUICreate("Form1", 220, 110)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 193, 21)
$Input2 = GUICtrlCreateInput("Input2", 16, 40, 193, 21)
$Button1 = GUICtrlCreateButton("Button1", 104, 64, 105, 41)
GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case - 3
                        Exit
                Case $Button1;;;;;;; 数字4,5,6,7,8,9 等数字 它计算的结果小于$K怎样才可以正确比对??
                        If GUICtrlRead($Input1) <= $k Then GUICtrlSetData($Input2, GUICtrlRead($Input1))
        EndSwitch
WEnd

zhenglei 发表于 2011-1-8 21:44:00

谢谢老大们的热情帮助。嘿嘿。。。。。有你们真好。。。。

_ddqs. 发表于 2011-1-8 22:57:04

为什么4都大于300(非数字)
---------------------------------
字串型数据比较:
从前面截取相同长度的字符
然后进行比较
if 4 <= 3 then ;条件非真,这里当然就没有动作了
if 10 <= 30 then ;比较为真,这里就可以搞点小动作
...
页: [1]
查看完整版本: 读取配置文件数值进行比对为什么4都大于300????