form1-login

Imports System.data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim f2 As Form2
Dim f3 As Form3
Dim i, j, k As Integer
Dim a, b, c As String

#Region ” Windows Form Designer generated code ”

Public Sub New()
MyBase.New()

‘This call is required by the Windows Form Designer.
InitializeComponent()

‘Add any initialization after the InitializeComponent() call

End Sub

‘Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

‘Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

‘NOTE: The following procedure is required by the Windows Form Designer
‘It can be modified using the Windows Form Designer.
‘Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
Me.SuspendLayout()

‘Label1

Me.Label1.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(96, 16)
Me.Label1.Name = “Label1”
Me.Label1.Size = New System.Drawing.Size(200, 48)
Me.Label1.TabIndex = 1
Me.Label1.Text = “Assignment 4”

‘Label2

Me.Label2.Location = New System.Drawing.Point(56, 112)
Me.Label2.Name = “Label2”
Me.Label2.TabIndex = 2
Me.Label2.Text = “Username”

‘TextBox2

Me.TextBox2.Location = New System.Drawing.Point(208, 112)
Me.TextBox2.Name = “TextBox2”
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = “”

‘TextBox3

Me.TextBox3.Location = New System.Drawing.Point(208, 152)
Me.TextBox3.Name = “TextBox3”
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(120)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = “”

‘Label3

Me.Label3.Location = New System.Drawing.Point(56, 152)
Me.Label3.Name = “Label3”
Me.Label3.TabIndex = 4
Me.Label3.Text = “Password”

‘Button1

Me.Button1.Location = New System.Drawing.Point(120, 200)
Me.Button1.Name = “Button1”
Me.Button1.Size = New System.Drawing.Size(128, 32)
Me.Button1.TabIndex = 6
Me.Button1.Text = “Enter”

‘LinkLabel1

Me.LinkLabel1.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LinkLabel1.Location = New System.Drawing.Point(32, 248)
Me.LinkLabel1.Name = “LinkLabel1”
Me.LinkLabel1.Size = New System.Drawing.Size(88, 23)
Me.LinkLabel1.TabIndex = 7
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = “Sign up”

‘Form1

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(416, 302)
Me.Controls.Add(Me.LinkLabel1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Icon = CType(resources.GetObject(“$this.Icon”), System.Drawing.Icon)
Me.Name = “Form1”
Me.Text = “START UP”
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()

End While
dr.Close()
cn.Close()
End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = 0
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
If TextBox2.Text = dr(0) And TextBox3.Text = dr(1) Then
j += 1
i = 1
Exit While
End If
End While

If i = 1 Then
MsgBox(“Authorised user ” & ” Roll number = ” & dr(2))
TextBox3.Text = “”
f3 = New Form3
f3.Show()
f3.label15.text = dr(0)
Else
MsgBox(“unauthorised user”)
TextBox3.Text = “”
End If
dr.Close()
cn.Close()
End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
f2 = New Form2
f2.Show()
End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s