lhy6456210 发表于 2011-5-15 13:33:06

求助循坏读取文件行对比的问题

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 192, 80, 249, 21)
$Label1 = GUICtrlCreateLabel("输入要验证的编号:", 80, 80, 103, 17)
$Button1 = GUICtrlCreateButton("跟INI文件对比存不存在相同的", 144, 144, 305, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
      Case $Button1
                        _az()
                                       
        EndSwitch
WEnd
Func _az()
$read=GUICtrlRead($Input1)
$fo=FileOpen("d:\name.txt")
While 1
$txtr=FileReadLine($fo)       
If @error = -1 Then ExitLoop
If $read=$txtr Then
        MsgBox(0,"","存在")
        ExitLoop
Else
        _bz()
EndIf
WEnd
EndFunc       

Func _bz()
MsgBox(0,"","我被跳了")       
       
EndFunc现在的代码是,读取到第一行如果不相等,就跳到_bz()这个部份了(按正常来说。应该是读取所有行对比后,不相等,才跳转到 _bz()),我要实现的效果是:读取输入框的内容,然后跟name.txt文件对比,所有行都对比完成后,如果不存在,则转转至_bz(),如存在就提示存在:

name.txt的内容
532622198510020558
532926197706150714
533001197904150920
533001198208076039
533001198605280930
533001198703076618
533001198709150911
533001198801141217
533001198803267550
533001198805297219
533001199006150952
53300119910113511X
533001199103280046
533001199112065719
533001199202087217

netegg 发表于 2011-5-15 14:31:17

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 192, 80, 249, 21)
$Label1 = GUICtrlCreateLabel("输入要验证的编号:", 80, 80, 103, 17)
$Button1 = GUICtrlCreateButton("跟INI文件对比存不存在相同的", 144, 144, 305, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
      Case $Button1
                        _az()
                                       
      EndSwitch
WEnd
Func _az()
If StringInStr(FileRead('temp.txt'), GUICtrlRead($Input1)) Then
        MsgBox(0,0,'ok')
Else
        MsgBox(0,0,'no')
EndIf
EndFunc
页: [1]
查看完整版本: 求助循坏读取文件行对比的问题