Saturday, April 4, 2015

Loan Interest Solver in Visual Basic 6

Most of us experiencing some financial problems in our lives we need to borrow money to support ourselves and our family. We cannot deny the reality in life that it is not easy to earn money for a living especially our economy is not stable enough to provide most people secure jobs to have a steady income.  When we make a loan from a bank, financial institution like a lending company or individual person the money that we loan has a interest for them to earn their money in return. That is called investment of their money in business stand of point. There are several agreements that the lender and the creditor can be agree for example let say a person would like to loan of an amount of $2000 the interest rate that is being agreed by both parties including the lender and the creditor is 10% per month interest rate payable for within two months for example.  That will be $200 dollars per month for two months it will be $400 to the total amount to be paid per month is $1200 for two months the total amount that is due is $2400. This computation is very simple is we are dealing only with monthly payment for a small amount.

How about if the loan is big amount let say $10,000 with 5% interest per year  or annum and payable for 10 years with compounded interest penalty rate if the payment was not able to be paid within the set payment schedule? What is the correct formula to derive to the solution to the problem to answer this question I created a program in Microsoft Visual Basic 6 I called this program Loan Compound Interest Solver.  This program will help the creditor and its customer compute the interest amount to be paid per year depending to the amount to be loaned, the interest rate that is being agree and the number of years the amount to be paid to the creditor or lender of the money.

I make the program very easy to use and does not use complicated programming codes to compute the interest rate of the amount to be paid. The first step that we do is the creation of the graphical user interface that will interact to the end user of our program. In this case we have a first label that will ask the user what is the principal amount to be loaned the value is being stored in a textbox we named the textbox txtAmount.text.  The second label we are the user to enter the interest rate we store the value in a textbox named txtInterest.txt  in this case we use numerical value rather than putting a number with a percentage symbol to avoid confusion on the part of our end user. The third label our program will ask again the user now many years to be paid in this portion every year there is a computation that is being performed by our program to get the amount that should be paid by the customer to its creditor for example a bank or any financial institution the variable that we will use for the storage of the years to be paid will be store in txtYears.txt.

After these values is being provided by the end user of our program the next step is for the user to press or click the compute button to perform a series of computation that shows the amount to be paid every year and the amount including its interest in our list box.  When the values is being listed in our list box the user has the option to clear the values by selecting the clear button it will erase all the contents of computation in the list box and the values in the text box so that the user can put a new set of values to be computed by our program. If the user is done all the computation the user is given a chance to quit the program by pressing the quit button. This quit button will display a confirmation dialog box that asking the user if the user is really sure to quit the program or not.  

Below is the complete program listing of our Loan Compounded Interest Solver.


Option Explicit

Private Sub cmd_compute_Click()
 Dim years, years2 As Integer
              Dim Interest_Rate_Value As Double
Dim Amount_Loaned As Currency
Dim Principal_Amount As Currency
lstdisplayvalues.Clear
years = Val(txtYears.Text)
Principal_Amount = Val(txtAmount.Text)

Interest_Rate_Value = (Val(txtInterest.Text) / 100)

lstdisplayvalues.AddItem vbTab & " Year " & vbTab & " Amount On Deposit "

For years2 = 1 To years

                Amount_Loaned = Principal_Amount * (1 + Interest_Rate_Value) ^ years2
 lstdisplayvalues.AddItem vbTab & Format$(years2, "@@@@") & vbTab & _
                          Format$(Format$(Amount_Loaned, "Currency"), _
                          String$(17, "@"))
 Next years2
End Sub

Private Sub cmd_quit_Click()
Dim reply As String
reply = MsgBox("Do you want to quit program?", vbYesNo + vbQuestion + vbDefaultButton2, "Quit Program")
If (reply = vbYes) Then
  Unload Me
  Else
  frmloan.Show
                 frmloan.txtAmount.SetFocus
                End If
End Sub

Private Sub cmdclear_Click()
txtAmount.Text = ""
txtInterest.Text = ""
txtYears.Text = ""
lstdisplayvalues.Clear
txtAmount.SetFocus
End Sub

This program is not complicated but simple enough that everyone that is interested how to write a loan compounded interest solver program will have a good idea how to start from int. If you want to improve your skills and knowledge in programming always write in a piece of paper what is the desired output of the program, what are the important requirements before you can write a single line of code. By doing this you can more focusing on solving the problem because you have already a clear picture on how the program will be developed and implement.  Good planning means faster the implementation of the project specially in software development.  If you have some questions, comments and suggestions feel free to contact me I am eager to answer your queries about this matter.


Thank you very much and Happy Productive Programming Everyone.





Sample Program Output



Student Record System in Visual Basic 6

In this simple program I would like to share with you a CRUD application that I called student record system that is written in Visual Basic 6 and Microsoft Access. It enables the user to add, edit and delete record of the students from the database. It stores student records like course, section and other related information about the student enrolled in the school. I also added a code for login so that only authorized users can only access the records from our system.


If you have some question send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.


Thank you very much.








Factorial in Visual Basic 6


In the part article that I have already wrote this type of program about factorial of numbers if you are wondering why I wrote this another factorial program my answer is very simple to give you an idea how to write a factorial program using Microsoft Visual Basic 6 as our programming language for program development. As a programmer we are not always dealing with one programming language all the time the reason is the programming has a wide range of application and not all programming language fits in a particular application. I will give you some insights if you want to create a program that deals with the hardware of the computer you can use C++ or C to handle for a job because it is designed for systems programming you can’t use this programming language in making webpage because it is not designed with it use HTML and CSS instead.  I used Microsoft Visual Basic 6 in this application because of its ease of use I my thesis in my college days we used it as our programming language for our thesis in titled “Computers Semi-Encyclopaedia” what is good about this language is that you can draw the different objects or I would say control and then after you design you can put the code for its control and run the program. It can save you big amount of time in designing you application you can more focus in solving the program is a short period of time.

This number factorial program is based on the concept in computer science called recursion algorithm. I will give you some idea what is a recursion is all about. In simple words we can say recursion is the ability of the function to call itself several times during the program execution in order to solve the program one of the basic application of recursion is factorial of numbers, tower of Hanoi and Fibonacci number as an example.  The recursion algorithm was developed by Dr. Stephen Cole Kleene in 1930 he is an American mathematician and a computer scientist who contributed many concepts in computer science.

Before we can write a single line of code for our program number factorial program we need to design our user interface. In our form we put a label that tells the user to enter a number take note we are dealing here with whole positive number and then it followed by our textbox where the use put a value.  The next portion is we have two command button the first button will performed computation and the other one will allow the user to quit the program. In order for us to display the list of numbers I am using List Box control in Visual Basic that advantage of using this control is that is automatically put a vertical scroll bar when the values exceed the size of our list box as we put in our window form.

Here is the function that I wrote for solving the factorial value of a number. What this function will do is to accept a number as its parameter in this case variable y if y <= 1 then the value is 1 it means if the user will only give 1 as the number in our text box it will return 1 as its default factorial value.  If the value of variable y is greater than 1 it will call itself  again and decrement the value of y until such time we arrive with the final answer let say the user will give 4 as its factorial value 4! = 4! * 3! * 2! * 1! = 24.  So the final value of 4! Is 24 we subtract 1 every time our loop statement call itself.  The important of using function compared with writing the code in a straight forward manner is that we can call the function several times in our program without writing the same code all over again it helps us to cut down the development time of our program and minimize the errors that might occur in during program development process.

Private Function Solve_Factorial(ByVal y As Double) As Double
If y <= 1 Then
    Solve_Factorial = 1
   Else
    Solve_Factorial = y * Solve_Factorial(y - 1)
  End If
End Function

In the general declaration we use Option Explicit it means every variable in our program should be declared with its corresponding data types.  It is very important to declare all the variable with its corresponding data type because we will know what is corresponding value should be used in our program. The next portion our code is the call of solve button here we have two variable a and b we declare it integer as its data types. We clear the list box values by calling this command lstValues.Clear the b variable is being used as our assignment operator we assigned for Val(Form1.txtvalue.txt) the keyword Val is a function In Visual Basic 6 to convert text value in a text box into an integer format.  As we go along we use a for loop statement variable a = 0 to b will add the items in our list box by using this commands For a = 0 To b   lstValues.AddItem Format$(a, "@@") & "! = " &    Solve_Factorial((a)) and calling our function called Solve_Factorial(a) and we exit in our loop statement.

Private Sub cmd_solve_Click()
 Dim a As Integer, b As Integer

 Call lstValues.Clear
 b = Val(Form1.txtvalue.Text)

  For a = 0 To b
   lstValues.AddItem Format$(a, "@@") & "! = " & _
   Solve_Factorial((a))
   Next a
End Sub

The last portion of our code is the quit bottom what is code will do when the user click the bottom it will ask the use if the user want to quit the program or not is the user will continue to use the program it will return to the form window and erase the previous value given by the user. If the use choose to quit the program will be terminated and the user return to the windows environment.

Private Sub cmdquit_Click()
Dim reply As String
reply = MsgBox("Do you want to quit program?", vbYesNo + vbQuestion + vbDefaultButton2, "Quit Program")
If (reply = vbYes) Then
  Unload Me
  Else
  Form1.Show
  Form1.txtvalue.SetFocus
 End If
End Sub

The program Number Factorial program is not difficult to write and develop what is very important for us to know the is our desired output and the formulas need to solve that particular problem in hand. If you have some questions feel free to email me I am very happy to answer your questions , comments and suggestions.

Thank you very much and Happy Productive Programming.


If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360






Sample Program Output






Power of a Number in Visual Basic 6


One of the interesting aspects of computers it is designed to perform computation as its first real application to mankind.  Very fast computation that even a human being that is very intelligent in the field of mathematics cannot compete with the speed and accuracy of the computer provided that the program that is being stored and run is correct and there is not errors or bugs on it.  For the information of our readers of this article the first electronic computer was ABC computer that was invented and developed by Dr. John D. Atanasoff and his student Clifford Berry. When we say it first electronic computer it means it doesn’t use any mechanical part not any moving parts all the operation that is being perform is done electronically by switches and logic gates.  This astonishing ability of the computer prove to be useful to us we when visit a bank we can check how much money that we have deposit or withdraw without going to the manual process of opening the filing cabinet and checking those enormous files of papers it save us big amount of time and we can lessen the errors on the part of the teller in the bank for example.

In today’s article I will discuss a very simple program called Power of a Number using Microsoft Visual Basic 6 as our programming language.  If you are new with programming you may ask the question what the heck is Visual Basic is all about why it is so different with other programming language that is being used in school, industry and company. Well before I answer that question let me give you a brief history on how Microsoft Visual Basic 6 came to life. The BASIC (Beginners All-Purpose Symbolic Instruction Code) is a programming language developed in Darthmouth College in Delaware, USA at 1963 by Dr. John Kemeny and Thomas Kurtz their intention is to created a programming language that is easier to learned and understand by students and those people that are not technically inclined with the use computers during those years computers are mainly used by scientist, engineers and technician alike. They want to make programming accessible to common man that’s why they write the first compiler of BASIC.  As the language improved dramatically over the years of use Mr. Allan Cooper the father of Visual Basic would like to create a programming language that handles the design of the graphical user interface of the user by not writing down a single line of code for the design but rather putting a series of controls that a programmer can use to draw the different objects in the form where the program is being developed. The year 1991 Microsoft Corporation headed by Bills Gates collaborate with Allan Cooper to launch a new type of programming language based on BASIC they called it Visual Basic which become of the most highly successful programming language of the world.
One of the most basic feature of Microsoft Visual Basic that cannot be found on other programming language during its introduction in 1991 is that the ability of the programming to draw first the user interface without using a code for the layout and design and after that the use of minimal amount of code to achieve its desired program result. The obvious benefit of using this programming paradigm it cuts down the big amount of time of system development and the programmer can focus more on solving the real problem in programming.  I hope you have learned something on the brief history of Visual Basic now let us go down of our problem Power of a Number.
Basically Power of a Number program it will performed a series of computations to derive the result when the user will give the base and the exponent value of the number.  The base number is the number that we want to raise its exponent value let say 5 is our base value when we want to raise it to the exponent 3 the result will be 5 * 5 * 5 is equal to 125 we just multiply our base number with itself by 3 times of the exponent value that we have given is 3 very simple indeed.

Before we can write a single line of code of our program we would like to design its graphical user interface this user interface is the one that will interact to our end user of our program. We have here three labels the first label will ask the user to enter the base value of the number, the second label will ask the user to enter the exponent value that we like and the third label is the lbl_result.caption it is designed to display the result once the use click the compute button of our program. Below here it the code in our compute button that will perform a computation to find the power value of the number.

The first line of command is option explicit this command will force the programmer to declare all the variables in our program. In Microsoft Visual Basic the language can allow the programmer to use a variable without declaring its data types in our case I use this command so that every variable that I use I will be force to declare it before I used it. It is a good programming practices that we must to follow always in our programming projects or assignments .

We three variables base, exponent, value and result we declare this four variables as integer it means we are dealing with whole number, positive, negative numbers including zero. The exponent variable here will act as our assignment system that will hold the value in our control Val(txt_exponent.text) and base with a value base = Val(txt_base.txt) take note readers the text field in Visual Basic 6 by nature the value that is being handled is string we are using Val() function to convert string value into integer format.

The next portion of our code we assign result with a value of 1 this mean this is the starting point of our initial value of 1  the purpose of result variable in our program is that it will accumulate the value of base with respect to the value of our exponent variable.  We are using a for loop statement below to repeat the process of multiplication of our base and result variable. After the series of repetition of our looping statement we display the result using a label control in this case we are using this command lbl_result.Caption = base & " to the power " & exponent &   " is " & result & "." this command tells us to display the value of base the ampersand symbol separate the string “to the power “ and exponent and it the result as we call our assignment statement to display the computed value of variable result.

Option Explicit

Private Sub cmd_compute_Click()
Dim base, exponent, value, result As Integer
exponent = Val(txt_exponent.Text)
base = Val(txt_base.Text)
result = 1
For value = 1 To exponent
   result = result * base
Next value
lbl_result.Caption = base & " to the power " & exponent &    " is " & result & "."
End Sub

This command button quick will display a dialog box and will ask the end user whether he or she would like to quit using our program Power of a Number if the user reply yes it will terminate the program using the command unload me if no it will display the form once again and clear all the values in the textbox including our label control.

Private Sub cmd_quit_Click()
Dim reply As String
reply = MsgBox("Do you want to quit program?", vbYesNo + vbQuestion + vbDefaultButton2, "Quit Program")
If (reply = vbYes) Then
  Unload Me
  Else
  frm_power.Show
  frm_power.lbl_result.Caption = ""
  frm_power.txt_base.Text = ""
  frm_power.txt_exponent.Text = " "
  frm_power.txt_base.SetFocus
 End If
End Sub

Writing this program is not difficult what is important you know the purpose and the formula we need in our program. A good programming tip that I can give to you plan first before you write a single line of code it will save you big amount of time and you can more focus in solving the problem on hand more effectively and efficiently. If you have some questions, clarifications or comments please email me I am very glad to answer those queries or questions you have in mind.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360


Thank you very much and Happy Programming.




Sample Program Output





Monday, March 30, 2015

Miles To Kilometers Converter in Javascript

In this article I would like to share with you another conversion program that I wrote using Javascript as my programming language I called this program Miles To Kilometers Converter. What does the program will do is to ask the user how many miles to be converted into kilometers equivalent. I also added some error handling codes which allows us to filter invalid values from our user of the program.


If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360






Program Listing

<html>
<title>Miles To Kilometer Converter </title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}  
</style>
<script language="JavaScript">
function kilomet()
  {
   
   var miles =document.getElementById("value1").value;
      if (isNaN(miles)|| (miles <0 ) || (miles =="")){
          alert (" Enter a valid number! Try Again... ");
          document.getElementById("value1").value = "";
          document.getElementById("value1").focus();
      }
else  { 
 solve= (miles * 1.60934);
 document.getElementById("kilo").value= solve.toFixed(5)
 document.getElementById("miles").value= miles;
    }
}

    function clear_me() {
    document.getElementById("kilo").value="";
document.getElementById("value1").value="";
document.getElementById("value1").focus();
}


  </script>
<body style='background-color:lightgreen'>
<div style='width:1100px;margin:auto'>
  <br> <h1 align="center">Miles To Kilometer Converter</h2>
  <br>
<div class="row"><label> How many miles </label>  <input type="text" name="value1"  id="value1"  value=""  size=5/> </div>
 <br><button onclick="kilomet();" 
 title="Click here to find equivalent of miles to kilometers.">
 Convert To Kilometers</button> 
 <button onclick="clear_me();" title="Click here to clear text fields.">
Clear</button> 
 <br><br><br>
 <div class="row"><label>  The  <input id="miles"  size="5" readonly> 
 miles is equivalent to <input id="kilo"  size="5" readonly> in kilometers. </label>   <br> </div>
  
<br> 
  </body>
</html>

Thursday, March 26, 2015

Area and Circumference of the Circle Using JavaScript

In this article I would like to share with you a sample program to solve the area and circumference of the circle in a given value by the user using Javascript as my programming language. What is good about this program I included a function to check if the value given by the user is numeric or not and a button that enables the user to clear the text box.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360






Program Listing

<html>
<title> Area and Circumference of the Circle Solver </title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}  
</style>
<script language="JavaScript">
   function solve_circle(){
   var radius =document.getElementById("value1").value;
      if (isNaN(radius)|| (radius <0 ) || (radius =="")){
          alert (" Enter a valid number! Try Again... ");
          document.getElementById("value1").value = "";
          document.getElementById("value1").focus();
      }
else  {
 solve= (radius * radius * Math.PI);
      circumference =   (2 * radius * Math.PI);
      document.getElementById("circle_area").value= solve.toFixed(2)
document.getElementById("circum_area").value= circumference.toFixed(2)
     }
}
    function clear_me() {
    document.getElementById("circle_area").value="";
document.getElementById("circum_area").value="";
document.getElementById("value1").value="";
document.getElementById("value1").focus();
}
</script>
<body style='background-color:lightgreen'>
<div style='width:1100px;margin:auto'>
  <br> <h1 align="center"> Area and Circumference of the Circle Solver</h2>
  <br>
<div class="row"><label> Enter a Number :</label>  <input type="text" name="value1"  id="value1"  value=""  size=5/> </div>
 <br><button onclick="solve_circle();" 
 title="Click here to find the area and circumference of the circle.">
 Find Area of the Circle</button> 
 <button onclick="clear_me();" title="Click here to clear text fields.">
Clear</button> 
 <br><br><br>
 <div class="row"><label>  The area of the circle is </label>  <input id="circle_area"  size="10" readonly> <br> </div>
  <div class="row"><label> The circumference of the circle is </label>  <input id="circum_area"  size="10" readonly></div> <br>
<br> 
  </body>

</html>

Tuesday, March 24, 2015

Feet To Meters Solver in PHP

In this simple program it will ask the user to enter a value in feet and then it will convert to its meters equivalent using PHP as our programming language. I also added validation function to check if the text field is empty or not and if the user give not a numeric value it will display an error message to the user informing that the value must be numeric in nature.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Program Listing

<html>
<title> FEET TO METERS SOLVER </title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

 // function to solve convert feet to meters

 function feet_to_meters($variable) {
           return($variable * 0.3048);
}

if(isset($_POST['check'])) {

     if (ctype_alpha($values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
  $values="";
 }
 
else if(preg_match('#[^a-zA-Z0-9]#', $values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
        $values="";
      
}

    else  if ($values=="") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a integer value.');";
  echo "</script>";
  $values="";
           }
else { 
      $title = "The equivalent value of ".$values." Feet(s) is " 
          .feet_to_meters($values)." Meter(s).";
       }  
   }  

if(isset($_POST['clear'])) {
  $values=" "; 
  $title=" ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> FEET TO METERS SOLVER </h2>
  <br>
<form action="" method="post">
 Enter a Number : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=20/>
   <input type="submit" name="check" value="Convert To Meters" 
  title="Click here to convert to meters equivalent."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br> 
<?php 
echo $title;
 ?>
  </body>
</html>


Monday, March 23, 2015

Diamond Pattern in PHP

In this article I would like to share with you a code that I wrote using PHP to display an image of an diamond using asterisk. The code is very short and easy to understand I'm just using for loop statement to create the diamond image.

If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360





Program Listing

<html>
<title> Diamond Pattern </title>
<body bgcolor="lightgreen">
<h1><font face="comic sans ms" color="red"> Diamond Pattern in PHP </face></h1>
<?php

$a=6; $b=0; $c=0; $space = 1;
  $space = $a - 1;
  for ($c = 1; $c <= $a; $c++)
  {
    for ($b = 1; $b <= $space; $b++)
    echo " &nbsp;&nbsp;&nbsp;   ";

     for ($b = 1; $b <= 2*$c-1; $b++)
     printf("<font size='6' color='red'> * </font> ");
     printf("<br>");
     $space=$space-1;
  }
  $space = 1;
  for ($c = 1; $c <= $a - 1; $c++)
  {
    for ($b = 1; $b <= $space; $b++){
     echo " &nbsp;&nbsp;&nbsp;  ";
     }
    $space++;
    for ($b = 1 ; $b <= 2*($a-$c)-1; $b++) {
      printf("<font size='6' color='red'> * </font> ");
 }
     echo "<br>";
  }
  ?>
 </body>
 </html>
  

Saturday, March 21, 2015

Inverted Triangle Pattern in c++

In this article I would like to share with you a sample program that I wrote using C++ as my programming language that will display an inverted triangle pattern image. For this code I'm using two for loop statement to achieve the pattern design of the inverted triangle.



If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



 Program Listing
#include <iostream>
#include <stdlib.h>

using namespace std;

   int a=0, b=0, c=0;
  
void display()
{

   cout << "\t INVERTED TRIANGLE";
   cout << "\n\n";
    for(a=20;a>=1;a-=1)
    {
        for(b=20;b>a;b-=1)
        {
                cout << " ";
        }
        for(c=1;c<(a*2);c+=1)
        {
                cout << "^";
        }
        cout << "\n";
    }
        cout << "\n\n";
}

int main()
{
    display(); 
    system("pause");
  }