找回密码
 加入
搜索
查看: 2998|回复: 4

[GUI管理] 菜鸟办法实现的一个功能,求更好的方法(内附代码)【已解决】

  [复制链接]
发表于 2011-8-23 23:06:01 | 显示全部楼层 |阅读模式
本帖最后由 xg911335 于 2011-8-24 21:18 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $i,$test,$accmdb_data_path,$accmdb_data_pws
$accmdb_data_path="data.accdb"
$accmdb_data_pws=""

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 292, 200, 192, 124)
$Button1 = GUICtrlCreateButton("下一个", 96, 72, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &$accmdb_data_path&";Jet Oledb:Database Password="&$accmdb_data_pws)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                                $RS.Open ("select work from tba")
                                while Not $RS.eof And Not $RS.bof
                                        if @error =1 Then ExitLoop
                                        $test = $RS.Fields (0).value
                                        $RS.movenext
                                        MsgBox(0,"test",$test)
                                        If Not GUIGetMsg() = $Button1 Then
                                                While 1
                                                        $nMsg = GUIGetMsg()
                                                                Switch $nMsg
                                                                        Case $GUI_EVENT_CLOSE
                                                                                Exit
                                                                        Case $Button1
                                                                                ExitLoop
                                                                EndSwitch
                                                        WEnd                                        EndIf        
                                WEnd
        EndSwitch
WEnd
循环读取数据库,点击"下一个"逐个显示。现求更好的方法。
发表于 2011-8-23 23:34:51 | 显示全部楼层
是and没有错,你可以不用while读取数据,每次点击,都movenext这样就好了哦
发表于 2011-8-23 23:51:02 | 显示全部楼层
好奇一點....你說希望有更好的解決辦法....是要解決哪些部分呢??  一個一個讀取問題嗎  還是....要把你的程式 寫的更精簡點..........

其實我個人不喜歡.....一個一個讀取數據 ....這樣要找不是都很累嗎??

我的作法通常會做 LISTVIEW.....然後 寫個 搜尋的功能........篩選出數據在丟回去LISTWIEW裡面...
這樣一次可以看多筆資料 有點類似查詢功能.....點選後 可以在編輯......

這的的操控性覺得 好多了...........
 楼主| 发表于 2011-8-24 12:09:49 | 显示全部楼层
不好意思。我没有表达好。是这样的。比如有个data.accdb.表名tba。字段ID,work,数据库内容如下:
id    work
1    123
2    234
3    345
…………
首先感谢coolvirus的回答,不过你给你代码不是我想要的功能。
我是想,点击“下一步”是逐个显示。如,第一次点击下一步的时候,显示123.第二次点击下一步的时候,显示234,第三次点击“下一步”显示345,以此类推。之所以问有没有更好的方法,是我不知道怎么实现这个功能。自己研究了很久,才发现我上面所发出来的代码可以这样实现功能。先找到一种解决方法,在来问问有没有更好或更理想的办法。
发表于 2011-8-24 13:12:46 | 显示全部楼层
本帖最后由 www378660084 于 2011-8-24 13:42 编辑


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $i,$test,$accmdb_data_path,$accmdb_data_pws
$accmdb_data_path="data.accdb"
$accmdb_data_pws=""

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 292, 200, 192, 124)
$Button1 = GUICtrlCreateButton("下一个", 96, 72, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &$accmdb_data_path&";Jet Oledb:Database Password="&$accmdb_data_pws)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("select work from tba")

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                    If Not $RS.eof And Not $RS.bof Then
                        $test = $RS.Fields (0).value
                        $RS.movenext
                        MsgBox(0,"test",$test)
                    EndIf
        EndSwitch
WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-17 16:49 , Processed in 0.076283 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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