Make login form and get user id login to next form on visual basic

make a login form on visual basic it's so easy, but we can make some creation to make an user id can identifiying on the next form,
follow thats instruction:
1. create new project, choice vb enterprise edition control
2. go to Project, references, include that :
- visual basic for apps
- visual basic runtime object and procedure
- ole automation
- microsoft access 9 object library
- microsoft activex data objects 2.51 library
- microsoft DAO 3.51 objects library
- microsoft data binding collection
3. add 2 form, login form and main form
4. on the login form, add 2 text and 2 command button, the include this code :

Private Sub form_load()
'open connection to db
cn.Open ("Provider= Microsoft.Jet.OLEDB.4.0;Persist security info=False;Data Source=" & App.Path & "\database.mdb" & ";Jet OLEDB:Database;")
End Sub

Private Sub Command1_Click()
'access table user "tbuser", with "if id=text1 anf password=text2", if one of them not correct then login would fail
rs.Open "Select*from tbuser where id='" & Text1.Text & "' AND Password ='" & Text2.Text & "'", cn, 3, 3
If rs.EOF Then
'EOF yaitu end of field or if did'nt find
MsgBox "ID not registered or incorrect password", vbOKOnly + vbExclamation, "Attention !"
Text1.Text = ""
Text2.Text = ""
'clear text1 and text2
rs.Close
'close
Else
'-----------------------------------------------------------------
'use this code to get user login name
With rs
strid_user = !id 'set strid_user same as id login
End With
rs.Close 'close recordset
'============
Unload Me 'close form login
Main.Show 'show form main
End If
End Sub

Private Sub Command2_Click()
cn.Close
Unload Me
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
' Enter
If KeyAscii = 13 Then
'TAB
SendKeys vbTab
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'TAB
SendKeys vbTab
End If
End Sub

5. on the main form add timer1, label 10, label11, label12, then include this code :
Private Sub form_load()
'load eeverything here
'show day
Ahari = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
SHari = Ahari(Abs(Weekday(Date) - 1))
'chow info
Label17 = "information of form"
'show user as login
Label10 = strid_user
'show date
Label12 = "" & SHari & ", " & Format(Date, "dd-mm-yyyy")
'call timer to show time
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Label11 = Format(Time, "hh:mm:ss")
End Sub
6. make a module then include this :
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset

Public strid_user As String
7. dont forget include database.mdb on link download bottom, and run your project, use p id = a pass = a...

good luck

still dizzy, get project and learn...
download here : (use pass : do-stupid-things.blogspot.com
login as user_pass_do-stupid-things.blogspot.com.rar - 31 KB

» Read More...

how to print all data in rich textbox on Visual Basic

now.., if you think to print all data on a richtextbox is a hard to do, you wrong just foolow that steps:
1. create new project
2. create new form, richtextbox, and one command1 button then include that code :

Private Sub Command1_Click()
Printer.FontName = "Courier New" 'font type
Printer.FontSize = "9" 'size
Printer.Print RichTextBox1.Text 'print all
'to printer
Printer.EndDoc
End Sub


3. turn on your printer, run your project, click command

good luck

just download the project : (use password : do-stupid-things.blogspot.com)
Print all in Rich TextBox.rar

» Read More...

Different of vbmodal, vbmodeles and only form show on visual basic

sometimes we need to create new form without close another or a form cannot be touched before new form closed, follow steps :
1. create new project
2. create form1, command1, command2, command3 on the form, include the code :

Private Sub Command1_Click()
Form2.Show vbModeless, Me
End Sub

Private Sub Command2_Click()
Form2.Show vbModal, Me
End Sub

Private Sub Command3_Click()
Form2.Show
End Sub

3. create form2, and run your project, looks the different

good luck

just download the project : (use password : do-stupid-things.blogspot.com)
different of vbmodal, vbmodeles and only form show on visual basic

» Read More...

Search This Blog

Recent Post

Popular Posts