找回密码
 加入
搜索
查看: 1006|回复: 3

帮我看看这段代码的问题?

[复制链接]
发表于 2009-7-21 15:12:47 | 显示全部楼层 |阅读模式
本帖最后由 xg911335 于 2009-7-22 10:30 编辑
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 223, 133, 338, 267)
$Input1 = GUICtrlCreateInput("", 72, 20, 121, 21)
$Button1 = GUICtrlCreateButton("test", 78, 98, 68, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1 
                        If @error = 1 Then
                                Exit
                        EndIf
                                $strlen = StringLen($input1)
                                MsgBox(0,"",$strlen);测试,   -----------------------------------这里怎么返回1啊?
                        If $strlen = "" Then
                                MsgBox(16,"1","你没有输入任何数字,请重新输入")
                        ElseIf StringIsDigit($input1) <> 1 Then ;-----------------------------------这个地方也有问题。
                                MsgBox(16,"2","您输入的包涵其它字符")
                        ElseIf $strlen <> 13 Then ;-------------------------------------------------不管是值是空还是什么都在判断在这里来了?
                                MsgBox(16,"3","您输入的数字可能小于13位或大于13位")
                        Else
                        Exit
                        EndIf

        EndSwitch
WEnd
我晕。我另外一个判断时间的小程序和上面一样,那个就没有问题,可这个怎么会出问题。
发表于 2009-7-21 15:35:08 | 显示全部楼层
本帖最后由 afan 于 2009-7-21 15:43 编辑
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 223, 133, 338, 267)
$Input1 = GUICtrlCreateInput("", 72, 20, 121, 21)
$Button1 = GUICtrlCreateButton("test", 78, 98, 68, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $strlen = StringLen(GUICtrlRead($Input1))
                        If $strlen = "" Then
                                MsgBox(16, "1", "你没有输入任何数字,请重新输入")
                        ElseIf StringIsDigit(GUICtrlRead($Input1)) <> 1 Then
                                MsgBox(16, "2", "您输入了含有数字以外的字符")
                        ElseIf $strlen <> 13 Then
                                MsgBox(16, "3", "您输入的数字为" & $strlen & "位,需要13位")
                        ElseIf $strlen = 13 Then
                                MsgBox(64, "ok", "搞定了,这才是正宗S13 ")
                        EndIf
        EndSwitch
WEnd
发表于 2009-7-21 15:51:33 | 显示全部楼层
本帖最后由 afan 于 2009-7-21 18:50 编辑

其实在 GUICtrlCreateInput 处修改一下,可以减少一些繁琐判断
而且,Case $Button1 里面的循环也是多余的
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 223, 133, 338, 267)
$Input1 = GUICtrlCreateInput("", 72, 20, 121, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 13)
$Button1 = GUICtrlCreateButton("test", 78, 98, 68, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $strlen = StringLen(GUICtrlRead($Input1))
                        If $strlen = 13 Then
                                MsgBox(64, "ok", "搞定了,这才是正宗S13 ")
                        Else
                                MsgBox(16, "no", "您输入的数字为" & $strlen & "位,需要13位")
                        EndIf
        EndSwitch
WEnd
发表于 2009-7-21 18:36:16 | 显示全部楼层
学习一下。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-6 07:30 , Processed in 0.070082 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表