Thursday, June 5, 2014

Keypress in Javascript

Being a freelance software engineer and web developer I must able to learn many programming techniques and tricks to improve myself and become more confident enough to handle programming projects of my clients. One of the interesting scripting language that caught in my interest is the JavaScript. This scripting language used primarily for the client side as a tool for form validation to ensure that the user gives right value or select correct options before the information send to the server side.

JavaScript is used also for animations and timer in most web applications it can integrate in HTML,CSS,PHP,ASP.NET,ColdFusion,ASP,PERL,CGI and other web technologies with ease. At present time there are many JavaScript framework that is freely available over the Internet to name as few we have the very popular one JQuery, Node.Js, AngularJS that add functionality in our webpages and websites.

Let us go with our sample program this program will ask the user to enter five numbers and then it will return the sum of the five numbers. What is good about this program is that the user just press the enter key and the cursor will move to the next text field automatically without using the mouse to navigate through text field.

I hope you will find my work useful thank you very much.



Sample Output of Our Program

Program Listing

<html>
<style>
p.margin
{
margin-top:10px;
margin-bottom:35px;
margin-right:350px;
margin-left:335px;
}
</style>
<script>

// June 5, 2014 Thursday
// Written By: Mr. Jake Rodrgiuez Pomperada, MAED-IT
// Email Address : jakerpomperada@yahoo.com  / jakerpomperada@gmail.com
// FaceBook Address: jakerpomperada@yahoo.com
// Product of the Philippines.


function enter_key(next_textfield) {
if(window.event && window.event.keyCode == 13) {
  next_textfield.focus();
  return false; 
  }
else
  return true; 
  }

   function add_all() {
    var a = parseInt(document.getElementById("no1").value);
    var b = parseInt(document.getElementById("no2").value);
var c = parseInt(document.getElementById("no3").value);
    var d = parseInt(document.getElementById("no4").value);
    var e = parseInt(document.getElementById("no5").value);
    
 var total_sum = (a + b + c + d + e);
 document.getElementById("test").innerHTML
   = "<p class='margin'>The total sum is " +total_sum + ".</p>";
}
function clear_all()
{
document.getElementById("no1").value="";
document.getElementById("no2").value="";
document.getElementById("no3").value="";
document.getElementById("no4").value="";
document.getElementById("no5").value="";
document.getElementById("test").innerHTML = "";
document.getElementById("no1").focus();
}
  </script>
<body bgcolor="yellow">
<font size="5" face="comic sans ms">
<br>
<h2> <center> Key Press Demonstration in Javascript 
</center> </h2>

<form name="test">
<p class="margin">
Item No. 1: <input type="text" id="no1" name="field1"
 onkeypress="return enter_key(document.test.field2)"><br>
Item No. 2 <input type="text" id="no2" name="field2"
 onkeypress="return enter_key(document.test.field3)"><br>
Item No. 3 <input type="text" id="no3" name="field3"
 onkeypress="return enter_key(document.test.field4)"><br>
Item No. 4 <input type="text" id="no4" name="field4"
 onkeypress="return enter_key(document.test.field5)"><br>
Item No. 5 <input type="text" id="no5" name="field5"
 onkeypress="return enter_key(document.test.send)"><br>
<br>

   <input id="send" type="button" value="ADD SUM"
    title="Click here to find the sum of numbers"
   onclick="add_all();" />
  <input id="clear" type="button" value="CLEAR"
    title="Click here to clear the all the text field."
   onclick="clear_all();" />
   <p id="test"></p> 
 </font> </p>
</form>
</body>
</html>








Multiplication Table Creator

One of my favorite programming language to write a program and play around in C++ programming language it is a very versatile programming language you can write different kinds of applications from systems application to business applications. What I learned in C++ give me confidence to learn much easier other programming language like C#,Java and PHP because there any many similarities in these programming languages is also based in C++.

In this article I will show you how to create a multiplication table creator in C++. This program will ask the user to enter first the row value and then the column value and our program will generate the multiplication table on our screen. Actually the program is very simple and easy to understand the code is very short. I wrote a function to generate the multiplication I called the function mul_table. The logic of our program is the use of nested for loop statement, I also used setw statement that can be found in the use of a C++ library file called #include <iomanip> it is mean input and output manipulator used primarily for text formatting in C++.


int mul_table(int row, int column)
 {
  cout << "\n\n";
  cout << "\t  MULTIPLICATION TABLE";
  cout << "\n\n";
  for (int x=1; x<=row; x++) {
         cout << "\n";
        for (int y=1; y<=column; y++) {
         cout << setw(5) << x * y;

        }
    }
 }

I hope you will find my work useful thank you very much.



Sample Output of Our Program


Code::Blocks text editor that I used in writing this program


Program Listing

// multiplication table creator
// Written by: Mr Jake R. Pomperada, MAED-IT
// Tools : Code:Blocks and Dev C++
// June 5, 2014 Thursday


#include <iostream>
#include <iomanip>

 using namespace std;

int mul_table(int row, int column);


 int mul_table(int row, int column)
 {
  cout << "\n\n";
  cout << "\t  MULTIPLICATION TABLE";
  cout << "\n\n";
  for (int x=1; x<=row; x++) {
         cout << "\n";
        for (int y=1; y<=column; y++) {
         cout << setw(5) << x * y;

        }
    }
 }

main() {
    int numbers[2];
    cout << "\t Multiplication Table Creator ";
    cout << "\n\n";
    cout << "Enter Row Number    :=> ";
    cin >> numbers[0];
    cout << "Enter Column Number :=> ";
    cin >> numbers[1];
    mul_table(numbers[0], numbers[1]);
    cout << "\n\n";
    system("pause");
}






Celsius To Fahrenheit Conversion


One of the basic programming problems that is given by teachers in computer programming is conversion of values in this example we have Celsius To Fahrenheit Conversion that I wrote using Python as our programming language. This program is very simple I just wrote it to learn the fundamental concepts of Python programming language and also to share this code for individuals and beginners that are interested in Python programming.

The formula to convert Celsius to Fahrenheit is (Celsius * 1.8) + 32 the Celsius here is the value that is given by our user of our program multiplied by 1.8 after we add the value 32 to get the converted results to Fahrenheit.

Below is a function in Python that I wrote to convert Celsius To Fahrenheit.

def  convert_to_celsius(celsius):
  solve = (celsius * 1.8) + 32
  print("Temperature is Celsius is {:.2f}".format(solve));
  return



Sample Output of Our Program


Python Integrated Programming Environment


Program Listing

# Celsius To Fahrenheit Converter
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 5, 2014 Thurday

def  convert_to_celsius(celsius):
  solve = (celsius * 1.8) + 32
  print("Temperature is Celsius is {:.2f}".format(solve));
  return

print("\n")
print("@==================================@")
print("     Celsius To Fahrenheit Converter     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 temp = float(input("Kindly Enter Temperature in Celsius :=> "))
 print("");
 convert_to_celsius(temp);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       






Wednesday, June 4, 2014

Factorial of a Number in Python


Recently I am trying to learn how to program in Python programming language one of the most programming problem is called Factorial of a Number. In factorial we refer to a number that is the product of all the integers from 1 to the the number given by our user. For example the factorial of 5! is 1*2*3*4*5 is equal to 120. When we talk about integer will refer this to a series of numbers that are whole number, negative,zero and positive number. Factorial numbers is not defined for negative number and zero will always gives you 1 as your value.

In this program I have written a simple factorial function to return factorial value result to the user of our program. As we can see in this function factorial we have one passing parameter we named it number and then an assignment statement solve_results which has an initial value of 1. We are also using for loop statement to perform the repetition of our commands and finally we have the solve_results that perform summation of values and it returns the computed value of our program.

def factorial(number):
    solve_results = 1
    for i in range(2, number + 1):
        solve_results *= i
    return solve_results
  

Sample Output of Our Program


Python Integrated Programming Environment

Program Listing

# Factorial of a Number 
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 4, 2014 Wednesday

def factorial(number):
    solve_results = 1
    for i in range(2, number + 1):
        solve_results *= i
    return solve_results
  
complete = False

while complete == False:

  print("@==================================@")
  print("      Factorial of a Number     ")
  print("@==================================@")
  print("");
  value = int(input("Kindly Enter a Number :=> "))
  print("");
  if value < 0:
    print("Sorry, factorial does not exist for negative numbers")
  elif value == 0:
    print("The factorial of 0 is 1")
  else:
    print("The factorial of",value,"is",factorial(value))
    print("")
  choice = input("Are You Finish?  Y/N: ").lower().strip()

  if choice == "y":
         complete = True
  else:
       print("")
  print("\n")
  print("Thank You For Using This Program.")
  



Tuesday, June 3, 2014

Fahrenheit To Celsius Converter in Python


In this article I will share with you a sample program that I wrote using Python programming language I called this program Fahrenheit To Celsius Converter in Python. I have already written this type of program in other programming languages in Visual Basic 6, Visaul Basic NET,C, C++, Java and PHP. I would like to try to convert the code using in Python in this program I wrote a function to solve and convert the temperature given in Fahrenheit into its Celsius equivalent. To find the Celsius temperature we are using this formula (°F - 32) x 5/9 = °C.

def  convert_to_celsius(fahrenheit):
  celsius = (fahrenheit - 32) * 5.0/9.0
  print("Temperature is Celsius is {:.2f}".format(celsius));
  return

Function in Python to solve the Celsius temperature equivalent

I hope you find my work useful and Thank you very much.



Sample Output of Our Program


Python Integrated Programming Environment


Program Listing

# Fahrenheit To Celsius Converter
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 3, 2014 Monday

def  convert_to_celsius(fahrenheit):
  celsius = (fahrenheit - 32) * 5.0/9.0
  print("Temperature is Celsius is {:.2f}".format(celsius));
  return

print("\n")
print("@==================================@")
print("  Fahrenheit To Celsius Converter     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 temp = int(input("Kindly Enter Temperature in Fahrenheit :=> "))
 print("");
 convert_to_celsius(temp);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       






Login and Registration System in PHP and MySQL


For every websites in the Internet needs a form of security the most common security application that is being develop is login and registration system. Having a secured website is very important to insure that only the valid users are allowed to login and use the system. In this article I will show you how to create a login and registration system using PHP and MySQL.

This program is database driven we are using MySQL to save and retrieve the users records such information is the username,password, first name and last name of the user. One of the feature of the program is that I checks whether the username and password is already used by other user. I also added some features to validate invalid or erroneous values from our user. For the validation I use JavaScript to check for invalid entries and to minimize errors using the execution of our program. I also included an SQL dumb file for the creation of our database, tables and insertion of sample records.

I hope you will find my work useful in your programming projects and assignments using PHP and MySQL.

Thank you very much.




Sample Output of Our Program




Engine Monitoring System in PHP and MySQL

This application is written in PHP and MySQL designed to monitor the engine usage in a company. It monitors how many hours the engine runs. It is primarily for the maintenance of the engine in a factory or manufacturing firm. It also stores how many kilowatt hour being consumed by the engine.
This program has a menu for a navigation of the user. The first menu is to add records about the engine; it will store all the records in the database. The second navigation link is the view of records which allows the user of the system to view the list of dates, engine serial number, number of how the engine run and the kilowatt hour consume by the said engine. The third navigational link is for the search of record. In the search record the program will ask the user to enter the engine serial number to be search and the date it will search for the specific records that matched with the criteria given by the user.
The tools that I used in making this application are notepad++ that is free to download from the internet at http://notepad-plus-plus.org/. This editor is good in writing html, css, javascript, php and mysql codes. It is very user friendly and very easy to use. This editor is highly recommended for those beginners in web programming.
The PHP and MySQL compiler used is XAMPP that can be downloaded freely at http://www.apachefriends.org/en/xampp.html. Very nice PHP and MySQL compiler to be used the user interface is excelled to navigated. In terms of the web browser, I’m using Google chrome which is very good in testing your web pages and websites.
In using my code, once you download the code extract the code in the directory of xampp in htdocs and then create a database name engine at the phpmyadmin and then select the database named engine and then select import choose the sql dumb file named engine.sql and select go button. To create the table name records and insert a couple of records in the table.
After you have done that you are already to run the script, make sure you create a folder under htdocs, for example engine and put those downloaded file on it. In testing about this program in your web browser address bar type the following: let say http://localhost/engine/index.php it will run the index.php as your main menu of the system. But before you run make sure the XAMPP system is activated. I hope you will able to run successfully.
                      


Sample Output of Our Program



                    

Fahrenheit To Celsius Converter in Visual Basic NET

Software becomes the driving force of information technology at present time, most of us are very dependent on software in doing our day to day task or work.  For example if you are an office clerk your main job is to prepare the documents, worksheet and presentation for instance we need to use a complete application to do the work that we need. That's why we use Microsoft Office like ms work, ms excel and ms power point to do the job.  This software are very complex that it requires hundreds or even thousands of programmers to write this application. It also evolves many years of careful planning, design and development.  On the part of Microsoft Corporation they invest big amount of resources like money and facilities during the development of Microsoft Office applications before it will be released and sold in the market.

As a freelance developer I also encounter many challenging problems involving software design and development one of the most common problem is that the client or customer doesn't not have an adequate understanding about the real problem of their proposed information system that they are planning for me to developed. Another thing that I have observed once I was able to finish the system my client wants another features and changes for the system, if the changes related to my mistakes being a programmer I change it free from charge but if it related to features that are not included in an agreement that we have I charge them reasonable price for the services in programming.

In software design and development it is a must bust client and developer to set down and plan very well what are the needs, problems identified in the current system before the ball rolling in writing a code. Well organized planning will cut down the development time by half because the programmer can focus very well in solving the problem rather than thinking what are the additional problems to be solve in the proposed system whether the client needs a business application or system application this procedure is still applicable.  One of my close friend that is also a good application developer in Java told me during our college days solve first the problem before make some good design. I agree because once you solve the problem in algorithm it is easier for us to do the design.  I hope this advice that I shared with you will help you in your software development.


In this article I will discuss a simple program that I wrote in Microsoft Visual Basic .NET I called this program Fahrenheit To Celsius Solver. What this program will do is very simple it will ask the user to enter a value in Fahrenheit in our text box. By this time I gave the user the two option in solving the value of Celsius the first option is press the enter key and will give you the result in our label or the user can press the Solve Celsius button to get the result in the label in the form.  I also included a button to clear the label and the text box and finally the last button which enables the user to quit the program and return to our windows operating system. The code is very short and very easy to understand by beginning programmers in Visual Basic .NET.

Thank you very much.





Sample Output of Our Program

Program Listing

 Public Class frm_fahrenheit

    Private Sub txt_fahrenheit_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_fahrenheit.KeyPress
        If e.KeyChar = ControlChars.Cr Then 'Enter key
            lbl_result.Text = "The temperature equivalent in Celsius is " & _
                ((CInt(txt_fahrenheit.Text) * 9) / 5) + 32 & " Cº."
        End If
    End Sub

  
    Private Sub btn_celsius_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_celsius.Click
        lbl_result.Text = "The temperature equivalent in Celsius is " & _
                ((CInt(txt_fahrenheit.Text) * 9) / 5) + 32 & " Cº."
    End Sub

    Private Sub btn_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_clear.Click
        txt_fahrenheit.Clear()
        lbl_result.Text = " "
        txt_fahrenheit.Focus()
    End Sub

    Private Sub btn_quit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_quit.Click
        If MsgBox("Are you sure you want to quit?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "Quit Program?") = MsgBoxResult.Yes Then
            Me.Hide()
        Else
            Me.Show()
            txt_fahrenheit.Clear()
            lbl_result.Text = " "
            txt_fahrenheit.Focus()
        End If
    End Sub
End Class





Monday, June 2, 2014

Address Book in PHP and MySQL

An address book is a program that store the information of a person like name, home address, telephone numbers, mobile numbers, email address or even social media address like in Twitter, FaceBook, Instagram and others. This program is very useful to track down the contacts of your friends, relatives much easier compared of using of manual record keeping.

As I started my learning how to program in PHP and MySQL I learned how to create this address book from scratch the code in this program that I wrote is very simple it is intended for beginners and novice that are new in database development in PHP and MySQL. I also include SQL dumb file for easier creation of database and tables.

By the way the PHP and MySQL that I used in the creation of this program I used XAMPP that is freely available over the Internet free from charge. The text editor that I used in writing the commands in PHP and MySQL I used Notepad++ an open source text editor that has a professional features for ease of use in application design and development.

Thank you very much.


Sample Output of Our Program




Password Security System in Python


One of the biggest threat in computer system is the issue regarding computer security. Most of us are not aware the computer security is a very important topic to be learned in information technology. We have heard many stories that a certain bank there records is being access by hackers and other computer criminals on the loose. This criminals and hackers can access sensitive information such as credit card numbers and other personal information of the customers and clients of the bank. They can use this information to do transactions online or to sell credit card numbers in the Internet.

There are many security measures that are being developed to protect this sensitive and confidential records. The most common security that we often use is the use of username and password. We use this most of the time to open our email addresses, social media accounts just like Facebook, Twitter, Instagram  and among other social media websites. However the use of username and passwords has many loopholes that we must be aware of we must able to create a password and username that is not easy to understand by other people. As I read books and magazines about computer security scientist and computer experts suggest that the username and password must be a combination of letters,numbers or even special characters in order to have more secure username and password.

In this article I would like to share with your a very simple program that I wrote using Python as my programming language I called this program Password Security System in Python. The code is very simple I just use logical operators in Python that is the and condition and if - else statement. If the user provides invalid username and password our program will continue to ask the user to give the right user name and password by using a while loop statement in our program. Again there are many rooms for improvement of our program this is just a beginning how to write your our password security system in Python.

I hope you find my work useful and thank you very much.


Sample Output of Our Program


Python Integrated Programming Environment

Program Listing

print("\n")
print("$$$==================================$$$")
print("       PASSWORD SECURITY SYSTEM         ")
print("$$$==================================$$$")
complete = False

while complete == False:
 print("");   
 username = input("User Name :>> ").lower().strip()
 password = input("Password  :>> ").lower().strip()

 username1 = "admin"
 password1  = "123"

 username2 = "bill"
 password2 = "12345"

 if (username == username1 and password == password1):
     print("\n");
     print ("Access granted")
     print ("Welcome to the System")
     complete =True
     print("\n");   
     
 elif (username == username2 and password == password2):
     print("\n");
     print ("Access granted")
     print ("Welcome to the System")
     complete =True
     print("\n");   
    
 else:
     print("");
     print ("Access Denied  !!!")
     complete=False
     print("\n");   



Odd and Even Number Checker in Python


Learning is a continues process this is true specially we are working in the field of Information Technology. A field that everyday is changing in terms of new development in technology we must able to adapt new methods how to manage information to be beneficial not only to us but also to other people.

In this article I will continue my study and sharing my sample program using Python as my programming language by this time I called this program Odd and Even Number Checker in Python. Writing programs in Python makes me realize that this programming language is easy and simple to use anyone who reads my article I encourage each of you to give Python a try in your programming projects on hand it will make your life much easier and enjoyable way to write code.

What the program will do is to ask the use to enter a number and then our program will determine whether the number that is being given by the user is odd or even number. I write a simple function in python to determine if the number is an odd or even number. Below is the function that I wrote I name it check_value with a parameter that I named number.

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

I hope you will find my work useful and beneficial in your learning how to program in Python programming language.

Thank you very much.

Sample Output Of our Program


Python Integrated Programming Environment

Program Listing

# Odd and Even Number Checker
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 2, 2014 Monday

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

print("\n")
print("@==================================@")
print("    ODD AND EVEN NUMBER CHECKER     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 value = int(input("Kindly Enter A Number :=> "))
 print("");
 check_value(value);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       






Login System in Visual Basic .NET and Microsoft Access

Information is very important to us as human being this information is very useful in making decisions in our day to day lives.  Now every individuals is equip with different devices and gadgets which enables them to communicate, read news from the Internet, do some buying and selling in the Internet.  But the biggest question is how secure our information whether it is stored in the Internet or on our own computer.  Generally speaking one of the most important issues is all about computer security that most people is not bothered with. Why because some people think if you use difficult username and password in your computer or your account the in web you are already secure and having a peace of mind because you know no body has the access to your account but only you alone.

Again this presumption is not correct most of the time, hackers and other people that has a high level of technical skills and knowledge in computers were able to gather information about any person and use those information for their own benefit. We have heard many times hackers able to get and stoles thousands or even millions of credit card numbers from banks and financial institution worldwide and sold this credit card numbers including the information of the person online with the right price you can get one and use it in your shopping or  business transactions. Why this things happened because there are security issues and problems were discovered in banks information system that hackers will able to exploit. Sometimes this loopholes in the system was also discovered by bank employees or IT personnel in the bank that they have a direct access in the system.  As I said in any bank or even financial institution they should practice security audit from time to time to know what are the problems or bugs in their system to avoid to be the next victim of hackers or intruders.

In this article I will discuss and show you how to create a database drive login system using Microsoft Visual Basic .NET as my programming language and Microsoft Access 2007 as my database.  I called this program login system using Microsoft Visual Basic 2010 and Microsoft Access 2007.  To be honest this is my first database application that I wrote using Visual Basic .NET because most of the time I used Microsoft Visual Basic 6 as my tool in creating customized database application for my clients here in the Philippines.  But I think learning the new version of Visual Basic is very important skills in today's information technology driven society and also to upgrade my skills in programming tool.   By contrary database programming in Visual Basic .NET is much easier compared to Visual Basic 6 why because all the necessary commands for database access is already built in and the user interface is excellent in my own opinion.
I started designing first my user interface in a form I named the form login system in its caption. The background of the form I choose light green it is my own preference  you can select the colour that you want in your program it doesn't matter it is more of the personal choose. Next in line I draw two text box the txtusername and txtpassword that will accept the user name and password of the user. I also write the labels to give the use the idea what to do the first label asking the user to enter the user name, the second label is asking the user to enter the password.  There are also two command buttons the OK and CLOSE. The OK command button if the user already type the username and password  and then click the OK button it will check if the username and password exist in our table named login in our Microsoft Access database named user. If the user choose the close command button the program will close and it will return to our windows operating system. In my case the computer that I am using in writing and developing this program I am using  Microsoft Window 8.


About the code I make sure the code is short and easy to understand by my fellow programmer. I am using connection string to allow me to connect Microsoft access 2007 database to my visual basic code as usually we must use SQL statement to do some queries in our table. In our SQL statement we issue a command SELECT username,password FROM login where username=? and password=? this statement tell SQL that we select fields username and password to check if the username and password provided by our user in our form is correct or not.  I also use a function in Visual Basic .NET to convert username and password into lowercase the command is ToLower(). Every time a user type username and password even the user type in capital or combination of uppercase and lowercase our program will convert all the user name and password into lower case. If the user name and password is correct our program will congratulate the user is not it will give a chance to the user to key in once again the correct user name and password in our program.




Sample Output of Our Program


Program Listing


Imports System.Data.OleDb
Public Class frmlogin
    Private Sub Btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
        Dim con As New OleDb.OleDbConnection
        con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = ..\user.mdb"
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT username,password FROM login where username=? and password=?", con)

        cmd.Parameters.AddWithValue("username", Me.txt_username.Text)
        cmd.Parameters.AddWithValue("password", Me.txt_password.Text)

        Try
            con.Open()
            Dim read As OleDbDataReader = cmd.ExecuteReader()

            If read.HasRows Then
                read.Read()

                If Me.txt_username.Text.ToLower() = read.Item("username").ToString And Me.txt_password.Text.ToLower = read.Item("password").ToString Then
                    MsgBox("You have login in the system successfully.", MsgBoxStyle.Information, "For your information")
                    Me.Hide()

                ElseIf String.IsNullOrEmpty(Me.txt_username.Text) Or String.IsNullOrEmpty(Me.txt_username.Text) Then
                    MsgBox("Please make sure the username and password is not empty.", MsgBoxStyle.Exclamation, "Warning")
                End If

            Else
                MsgBox("Username and Password is incorrect. " & vbCrLf &
                       " Access Denied !!! Please Try Again.", MsgBoxStyle.Exclamation, "Warning")
                Me.txt_username.Text = ""
                Me.txt_password.Text = ""
                Me.txt_username.Focus()
            End If

            read.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            con.Close()
        End Try

    End Sub

    Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
        End
    End Sub
End Class