Create a Windows form

Source: Internet
Author: User
In the forum, I often see some friends in the vb version asking questions about login. This article provides some help for beginners. Of course, I hope that experts with better methods can give advice.

First file → new → project select windows application and add two label controls, two textbox controls, and two buton controls on the form, such as (1-1 ):

After the interface is designed, write the following code in the button click event:

(Reference imports system. Data. oledb at the top of the Program)

Private sub bok_click (byval sender as system. Object, byval e as system. eventargs) handles Bok. Click
'Definition
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' is defined as Boolean for subsequent error handling.
Dim I as integer
Olecm = new oledbcommand ("select * from login", olecn)
'Establish a connection with the database
Olecn. open ()
Olerd = olecm. executereader
'Cyclically determine whether the data in the database is the same
Do While olerd. Read ()
For I = 0 to olerd. fieldcount-1
If trim (Tuser. Text) = (olerd. Item ("account") and trim (tpassword. Text) = (olerd. Item ("password") then
Msgbox ("successfully logged on ")
Pd = true
Exit sub
End if
Next
Loop
Tuser. Text = ""
Tpassword. Text = ""
Tuser. Focus ()
Olerd. Close ()
Olecn. Close ()
End sub

The whole process is complete.

QQ: 174453914

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.