private sub bok_click(byval sender as system.object, byval e as system.eventargs) handles bok.click '定義 dim olecn as new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=data.mdb") dim olecm as new oledbcommand("select * from login", olecn) dim olead as new oledbdataadapter dim olerd as oledbdatareader dim pd as boolean = false '定義boolean為后面錯(cuò)誤處理使用 dim i as integer olecm = new oledbcommand("select * from login", olecn) '與數(shù)據(jù)庫建立連接 olecn.open() olerd = olecm.executereader '循環(huán)判斷與數(shù)據(jù)庫中數(shù)據(jù)是否相同 do while olerd.read() for i = 0 to olerd.fieldcount - 1 if trim(tuser.text) = (olerd.item("帳號")) and trim(tpassword.text) = (olerd.item("密碼")) then msgbox("成功登陸") pd = true exit sub end if next loop tuser.text = "" tpassword.text = "" tuser.focus() olerd.close() olecn.close() end sub