Friday, July 31, 2009

How to create a log in form on visual basic 6.0?

Basically i need it to have a PIN entry link to an access database and i need it to load another form if the pin is equal to any pin on the access document...





I also need to know how to show a report from access on a visual basic form..





Thanks muchly,


Leah

How to create a log in form on visual basic 6.0?
Steps:





1. Start a new Windows CE HPC Project in Visual Basic. Form1 is created by default.


2. Add a command button to Form1.


3. Paste the following code into the code module for Form1: Private Sub Command1_Click()


Form2.Show


' Warning: Code still executes despite the


' fact that Form2 will be shown modally.


Form1.Enabled = False


MsgBox "Form1 events still fire"


End Sub





Sub ValidatePassword(UID As String, PWD As String)


If UID %26lt;%26gt; "" And PWD %26lt;%26gt; "" Then


MsgBox "Login succeeded"


Form1.Enabled = True


Else


MsgBox "Login failed: Please try again"


Form2.Show


End If


End Sub








4. From the Project menu, click Add Form to add a new form.


5. Set the ControlBox property of Form2 to "False."


6. Add a command button, two labels, and two text boxes to Form2.


7. Paste the following code into the code module for Form2: Private Sub Form_Load()


ConfigureUI


Dim lret


lret = SetWindowPos(Form2.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)


End Sub





Private Sub Command1_Click()


Form2.Hide


Form1.ValidatePassword Text1.Text, Text2.Text


End Sub





Sub ConfigureUI()


Form2.Height = 2235


Form2.Width = 3400


Label1.Move 120, 120, 975, 375


Label2.Move 120, 600, 975, 375


Text1.Move 1100, 120, 1975, 375


Text2.Move 1100, 600, 1975, 375


Command1.Move 240, 1200, 2775, 495


Form2.Caption = "Please Log In"


Label1.Caption = "UserID"


Label2.Caption = "Password"


Text1.Text = "TestID"


Text2.Text = "TestPassword"


Command1.Caption = "Log In"


End Sub








8. From the Project menu, click Add Module to add a new module.


9. Paste the following code into Module1: Public Declare Function SetWindowPos Lib "Coredll" ( _


ByVal hwnd As Long, _


ByVal hWndInsertAfter As Long, _


ByVal x As Long, _


ByVal y As Long, _


ByVal cx As Long, _


ByVal cy As Long, _


ByVal wFlags As Long) As Long





Const SWP_NOMOVE = 2


Const SWP_NOSIZE = 1


Const HWND_TOPMOST = -1


Const HWND_NOTOPMOST = -2








10. Run the project.


No comments:

Post a Comment