Saturday, February 25, 2017

Login System With Three Times Attempt in Visual Basic 6 and Microsoft Access

In this article I would like to share with you guys the work of my best friend and fellow software engineer Mr. Dave Marcellana from Talisay City, Negros Occidental. This program we called Login System with Three Times Attempt in Visual Basic 6 and Microsoft Access which allows the user to login and it will stop the user if the given username and password is not correct in the three attempts that the user committed to the application. The program code is very simple and short very easy to understand and user. 

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output



Directory Structure




Database and Table Structure


Program Listing


Form1

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   If modUserLogin.UserLogin(Text1.Text, Text2.Text) = True Then
           
      MsgBox "Welcome " & rs!Role & "!", vbInformation + vbOKOnly, "Access Granted"
    End If
End If
End Sub


modMain.bas

Public rs As New ADODB.Recordset
Public cn As New ADODB.Connection
Public sql As String
Public dbpath As String

Sub main()
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection

With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
End With

dbpath = App.Path & "\database\database.mdb"

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & dbpath & ";Persist Security Info=False"
Form1.Show
End Sub

modUserLogin.bas

Public Function UserLogin(user As String, pass As String) As Boolean
If rs.State = 1 Then rs.Close

    sql = "SELECT * FROM tblSecurity WHERE Username='" & user & "'" & "AND Password ='" & pass & "'"
    rs.Open sql, cn
    'rs.Open sql, cn
    
If Not rs.EOF Then
    If rs!Role = "Administrator" Then
        UserLogin = True
    Else
        UserLogin = True
    End If
Else
    'frmLogin.fraError.Visible = True
    MsgBox "Wrong Username or Password! Try Again!", vbExclamation + vbOKOnly, "Access Denied"
    UserLogin = False
    Form1.lblcount.Caption = Form1.lblcount.Caption + 1
    
    a = Form1.lblcount.Caption

    If a > 2 Then
    MsgBox "Sorry! You've reached the maximum retries for entering a user account. The system will be closed.", vbCritical + vbOKOnly, "Access Denied"
    End
    End If

End If
End Function




Tuesday, February 21, 2017

Swap of Two Numbers Without Using Third Variable in Java


In this article I would like to share with you a program that will ask the user to give two integer numbers and then our program will swap or interchange the arrangement of two numbers without using third variable in Java. The code is very easy simple and easy to understand. I am using TextPad as my text editor in this sample program.  Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

swap.java


import java.util.Scanner;


class swap {

public static void main(String args[])
{

        int num1=0, num2=0;

        Scanner s = new Scanner(System.in);

        System.out.println();
        System.out.println("=== Swap of Two Numbers Without Using Third Variable in Java === ");
        System.out.println();

         System.out.print("Enter First Value : ");
         num1 = s.nextInt();

         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();

         System.out.println();
 System.out.println("===== BEFORE SWAPPING ======");
         System.out.println();
         System.out.println(num1 + "      "  + num2);

         num1 = (num1+num2);
         num2 = (num1-num2);
         num1 = (num1-num2);

         System.out.println();
    System.out.println("===== BEFORE SWAPPING ======");
         System.out.println();
         System.out.println(num1 + "      "  + num2);

         System.out.println();
         System.out.println("===== END OF PROGRAM ======");
         System.out.println();

      }
}  // End of Code




Display String in Java

In this article I would like to share with you guys a program that I wrote in Java to display a string values from a string variable that I have assigned with the code was designed for beginners that are very new in Java programming in general. I am using TextPad as my text editor in this sample program. I hope you will like it. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing


class display_str {

public static void main(String args[])
{

   String title = "Computer Programming is Fun and Interesting.";

            System.out.println("\n\n");
   System.out.println("\t"+title);
   System.out.println();
   System.out.print("\t\t"+"=====  END OF PROGRAM =====");
           System.out.println("\n\n\n");

    }

}
  // End of Code



Sunday, February 19, 2017

Getline in C++

In this article I would like to share with you a sample program that I wrote that shows you how to use getline command in C++ to get input value from our user.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <string>

using namespace std;

 main() {

  string address,name;

  cout << "Name ";
  cin >> name;
  cout << "Enter your complete address : ";
   cin.ignore(80,'\n');
   getline(cin, address);

 cout << "\n\n";
 cout << "Hello " << name;
 cout << "\n";
 cout << "You address is ";
 cout << address;
   cout << "\n\n";
   system("PAUSE");
 }

Pointer Address in C++

A simple program that I wrote a long time ago in C++ that shows how to use pointers to know the memory address of the variable. The code is very short and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>

using namespace std;

main() {
    int value = 10;

    int *ptrvalue;

    ptrvalue = &value;

    cout << "The original value is " << value;
    cout << "\n\n";
    *ptrvalue = 20;
    cout << "The new value is " << value;

    cout << "\n\n";
    system("PAUSE");
}

Factors of a Numbers in PHP

Hi there in this article I would like to share with you a sample program that will compute the factors of a given number in PHP. The code is very short and easy to understand. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing



<html>
<title> Factors of a Number </title>
<style>
body {
 font-family:arial;
 font-size:20px;
}
</style>
<body bgcolor="lightgreen">
<br> <br>
<?php
$val = $_POST['number'];

?>
<h3> Factors of a Number in PHP </h3>
<form method="POST" action="">
    <input type="text" name="number" value="<?php echo $val;?>" placeholder="Give a Number"></input>
    <br> <br>
    <input type="submit" value="OK"></input> &nbsp;&nbsp;&nbsp;
     <input type="submit" name="clear" value="Clear"></input>
</form>
<?php

  if(isset($_POST['clear']) && !empty($_POST['clear'])) {
   $display = " ";
   $val = " ";
   $a=" ";
   }
   
if(isset($_POST['number']) && !empty($_POST['number'])) {
         
       $display = "The Factors of $val is ";
       echo $display;
     for($a=1; $a <=$val; $a++)
    {
        if ($val%$a == 0)
        {
           
            echo  " ".$a." ";
        }
        }
 }             

?>
</body>
</html>

Quotient of Two Numbers in Java

In this sample program that I wrote it will ask the user to give two numbers and then our program will find the quotient of the two numbers and display the results on the screen using Java as our programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package quotient_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class Quotient_Two {

    /**
     * @param args the command line arguments
     */
   public static int div_two_number(int n1, int n2) {
      int div=0;
      
      div = (n1/n2);

      return div;
   } 
    void display()
    {
       int num1=0, num2=0, div_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Quotient of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         div_all = div_two_number(num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The quotient betweem " + num1 + " and "
                     + num2 + " is " + div_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      Quotient_Two demo  = new Quotient_Two();
      demo.display();
            
    }
    
}






Difference Between Two Numbers in Java

A simple program that I wrote using Java to ask the user to give two numbers and then our program will compute the difference between the two of them.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package diff_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class Diff_Two {

    /**
     * @param args the command line arguments
     */
   public static int sub_two_number(int n1, int n2) {
      int sub=0;
      
      sub = (n1-n2);

      return sub;
   } 
    void display()
    {
       int num1=0, num2=0, sub_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Difference of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         sub_all = sub_two_number(num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The difference betweem " + num1 + " and "
                     + num2 + " is " + sub_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      Diff_Two demo  = new Diff_Two();
      demo.display();
            
    }
    
}





Addition of Two Numbers in Java

A simple program that I wrote using Java as my programming language that will ask the user to give two numbers and then our program will compute the sum of the two number being provided by our user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output




Program Listing

addition_two.java


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package addition_two;


import java.util.Scanner;

/**
 *
 * @authors Jake R. Pomperada and  Jacob Samuel F. Pomperada
 * Date : February 19, 2017  Sunday
 * Language : Java
 * IDE     : NetBeans
 */
public class addition_two {

    /**
     * @param args the command line arguments
     */
   public static int addition_two_number(int n1, int n2) {
      int sum=0;
      
      sum = (n1+n2);

      return sum;
   } 
    void display()
    {
       int num1=0, num2=0, sum_all=0;

        Scanner s = new Scanner(System.in);
     
        System.out.println();
        System.out.println("=== Addition of Two Numbers Using Method in Java === ");
        System.out.println();
      
         System.out.print("Enter First Value : ");
         num1 = s.nextInt();
            
         System.out.print("Enter Second Value : ");
         num2 = s.nextInt();
                 
         sum_all =  addition_two_number((num1,num2);
  
        System.out.println();
        System.out.println("===== DISPLAY RESULTS ======");
        System.out.println();
        System.out.println("The sum of " + num1 + " and "
                     + num2 + " is " + sum_all + ".");

        System.out.println();
        System.out.println("===== END OF PROGRAM ======");
        System.out.println();
    }
    
    public static void main(String[] args)
      {
        // TODO code application logic here
      addition_two demo  = new addition_two();
      demo.display();
            
    }
    
}