Sunday, December 31, 2017

Positive and Negative Number Checker in Microsoft Access

A very simple program that I wrote using Visual Basic for Application in Microsoft Access 2000 to ask the user to give a number and then our program will check if the given number is a positive and negative number.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.







Sample Program Output



Program Listing

'Written By Mr. Jake R. Pomperada, MAED-IT
'December 31, 2017 Sunday
' Microsoft Access 2000

Option Compare Database

Private Sub Command5_Click()

Dim val_me As Integer

val_me = val(Me.Text2)


If Len(Trim(Me.Text2) & vbNullString) = 0 Then
     MsgBox "Enter a Number Please", vbInformation
     Me.Text2.SetFocus
     Exit Sub
End If

If (val_me >= 0) Then
   MsgBox ("The given number " + Trim(Str(val_me)) + " is a Positive Number.")
   Else
   MsgBox ("The given number " + Trim(Str(val_me)) + " is a Negative Number.")
  End If
End Sub

Private Sub Command6_Click()
Me.Text2 = ""
Me.Text2.SetFocus
End Sub

Private Sub Command7_Enter()
  MsgBox ("This program was written by Mr. Jake R. Pomperada")
End Sub








Palindrome in Android

Before the new year will arrive I would like to post my 300 article posting this 2017 I called this program Palindrome in Android which contains two program. The first program in String Palindrome which ask the user to give a string or a word and then our program will check if the given word or string is a Palindrome or not. The second one is number palindrome which ask the user to give a number and then our program will determine and check if the given number is palindrome or not. 

In addition I include about the program page which display about me as the developer of this application. I also added error checking code to avoid our application will crash is blank or empty spaces will be given by our user. I learned a lot in this application that I wrote and I want it to share to other programmers. I hope you will find my work useful.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.





Main Menu Page


Checking Empty Values Page


String Palindrome Page




Number Palindrome Page




About This Program Page


Quit Program Page


Genymotion the Android Emulation that I use in writing this application.



Program Listing

About.java

package com.blogspot.jakerpomperada.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class About extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
    }
}

MainActivity.java

package com.blogspot.jakerpomperada.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;

public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    public void string_palindrome(View v) {
        startActivity(new Intent(this, String_Palindrome.class));

    }
    public void number_palindrome(View v) {
        startActivity(new Intent(this, Number_Palindrome.class));

    }


    public void about_this_program(View v) {
        startActivity(new Intent(this, About.class));

   }
    public void quit(View v) {
        // Toast.makeText((getApplicationContext()), "This is my Toast message!",Toast.LENGTH_LONG).show();
        new AlertDialog.Builder(this)
                .setMessage("Quit This Program?")
                .setCancelable(false)
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        MainActivity.this.finish();
                    }
                })
                .setNegativeButton("No", null)
                .show();
    }
}


String_Palindrome.java

package com.blogspot.jakerpomperada.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;


import java.util.*;


public class String_Palindrome extends AppCompatActivity {
 int given_number;
    @Override    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_string__palindrome);

    }

   public void clear_edit_text(View v) {
       final EditText value_given = (EditText) findViewById(R.id.editValueGiven);
       final TextView result = (TextView) findViewById(R.id.lblresult);
        result.setText("");
        value_given.setText("");
        value_given.requestFocus();
    }


    public void check_string(View v) {
       final EditText value_given = (EditText) findViewById(R.id.editValueGiven);
       final TextView result = (TextView) findViewById(R.id.lblresult);

      String GetEditText = value_given.getText().toString();

        if(TextUtils.isEmpty(GetEditText)){

            Toast.makeText(this, "Cannot Be Empty. Kindly provide a string or a word.", Toast.LENGTH_SHORT).show();
            result.setText("");
            value_given.setText("");
            value_given.requestFocus();

        } else        {
            try {
                }catch (Exception  e){
                Toast.makeText(this, "Not a String", Toast.LENGTH_SHORT).show();
            }

            String  reverse = "";

            int length = GetEditText.trim().toLowerCase().length();

            for ( int i = length - 1; i >= 0; i-- )
                reverse = reverse + GetEditText.charAt(i);

            if (GetEditText.trim().toLowerCase().equals(reverse.trim().toLowerCase()))   {
                result.setText(GetEditText.toUpperCase() + " is a Palindrome String. ");
            } else {
                result.setText(GetEditText.toUpperCase() + " is not a Palindrome String. ");
            }

        }


        }

    }

Number_Palindrome.java

package com.blogspot.jakerpomperada.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.text.TextUtils;



public class Number_Palindrome extends AppCompatActivity {
 int given_number;
    @Override    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_number__palindrome);

    }

   public void clear_edit_text(View v) {
       final EditText value_given = (EditText) findViewById(R.id.editValueGiven);
       final TextView result = (TextView) findViewById(R.id.lblresult);
        result.setText("");
        value_given.setText("");
        value_given.requestFocus();
    }


    public void check_number(View v) {
       final EditText value_given = (EditText) findViewById(R.id.editValueGiven);
       final TextView result = (TextView) findViewById(R.id.lblresult);

      String GetEditText = value_given.getText().toString();

        if(TextUtils.isEmpty(GetEditText)){

            Toast.makeText(this, "Cannot Be Empty. Kindly provide a number.", Toast.LENGTH_SHORT).show();
            result.setText("");
            value_given.setText("");
            value_given.requestFocus();

        } else        {
            try {
                given_number = Integer.parseInt(value_given.getText().toString());
            }catch (NumberFormatException e){
                Toast.makeText(this, "Not a number", Toast.LENGTH_SHORT).show();
            }

            int i = 0, reverse = 0;

            int q = given_number;

            for (i = 0; i <= given_number; i++) {
                reverse = reverse * 10;
                reverse = reverse + given_number % 10;
                given_number = given_number / 10;
                i = 0;
            }

            if (reverse == q) {
                result.setText(String.valueOf(q) + " is a Palindrome Number. ");
            } else {
                result.setText(String.valueOf(q) + " is not a Palindrome Number. ");
            }

        }


        }

    }


activity_about.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@android:color/holo_green_light"    tools:background="@android:color/holo_green_light"    tools:context="com.blogspot.jakerpomperada.myapplication.About">

    <RelativeLayout        android:layout_width="368dp"        android:layout_height="495dp"        tools:layout_editor_absoluteX="8dp"        tools:layout_editor_absoluteY="8dp">

        <TextView            android:id="@+id/textView3"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentBottom="true"            android:layout_alignParentStart="true"            android:layout_marginBottom="40dp"            android:layout_marginStart="12dp"            android:gravity="left"            android:lines="10"            android:maxLines="17"            android:text="\nThis program was designed and developed by Mr. Jake R. Pomperada. I live in Bacolod City, Negros Occidental Philippines. \n\nYou can email me at the following email address jakerpomperada@yahoo.com and jakerpomperada@gmail.com  \n\nThank you for using this software."            android:textAppearance="@style/TextAppearance.AppCompat.Medium"            android:textColor="@android:color/background_light"            android:textStyle="bold" />

        <ImageView            android:id="@+id/imageView3"            android:layout_width="193dp"            android:layout_height="188dp"            android:layout_alignParentTop="true"            android:layout_centerHorizontal="true"            android:layout_marginTop="50dp"            app:srcCompat="@drawable/me"            tools:layout_editor_absoluteX="102dp"            tools:layout_editor_absoluteY="55dp" />

    </RelativeLayout>

</android.support.constraint.ConstraintLayout>


activity_main.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@android:color/holo_green_light"    tools:context="com.blogspot.jakerpomperada.myapplication.MainActivity">

    <LinearLayout        android:layout_width="368dp"        android:layout_height="495dp"        android:orientation="vertical"        tools:layout_editor_absoluteX="8dp"        tools:layout_editor_absoluteY="8dp">

        <Button            android:id="@+id/button21"            android:onClick="string_palindrome"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="30dp"            android:background="@android:color/background_light"            android:padding="20dip"            android:text="String Palindrome"            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />

        <Button            android:id="@+id/button22"            android:onClick="number_palindrome"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="30dp"            android:background="@android:color/background_light"            android:padding="20dip"            android:text="Number Palindrome"            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />

        <Button            android:id="@+id/button22"            android:onClick="about_this_program"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="30dp"            android:background="@android:color/background_light"            android:padding="20dip"            android:text="About This Program"            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />


        <Button            android:id="@+id/button22"            android:onClick="quit"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="30dp"            android:background="@android:color/background_light"            android:elevation="0dp"            android:padding="20dip"            android:text="Quit This Program"            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" />

    </LinearLayout>
</android.support.constraint.ConstraintLayout>


activity_number_palindrome.xml


<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@android:color/holo_green_light"    tools:context="com.blogspot.jakerpomperada.myapplication.Number_Palindrome">

    <RelativeLayout        android:layout_width="368dp"        android:layout_height="499dp"        tools:layout_editor_absoluteX="8dp"        tools:layout_editor_absoluteY="0dp">

        <TextView            android:id="@+id/textView2"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentTop="true"            android:layout_alignStart="@+id/editValueGiven"            android:layout_marginTop="25dp"            android:text="Enter a Number"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

        <EditText            android:id="@+id/editValueGiven"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_below="@+id/textView2"            android:layout_centerHorizontal="true"            android:layout_marginTop="27dp"            android:ems="10"            android:inputType="number"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

        <Button            android:id="@+id/button"            android:layout_width="279dp"            android:layout_height="wrap_content"            android:layout_alignEnd="@+id/editValueGiven"            android:layout_below="@+id/editValueGiven"            android:layout_marginTop="125dp"            android:background="@android:color/background_light"            android:onClick="check_number"            android:text="Check Number"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            tools:layout_editor_absoluteX="53dp"            tools:layout_editor_absoluteY="259dp" />

        <Button            android:id="@+id/button2"            android:layout_width="281dp"            android:layout_height="51dp"            android:layout_alignStart="@+id/button"            android:layout_below="@+id/button"            android:layout_marginTop="60dp"            android:background="@android:color/background_light"            android:onClick="clear_edit_text"            android:text="Clear"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            tools:layout_editor_absoluteX="78dp"            tools:layout_editor_absoluteY="378dp" />

        <TextView            android:id="@+id/lblresult"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignStart="@+id/button"            android:layout_below="@+id/editValueGiven"            android:layout_marginTop="41dp"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

    </RelativeLayout>

</android.support.constraint.ConstraintLayout>


activity_string_palindrome.xml


<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@android:color/holo_green_light"    tools:context="com.blogspot.jakerpomperada.myapplication.Number_Palindrome">

    <RelativeLayout        android:layout_width="368dp"        android:layout_height="499dp"        tools:layout_editor_absoluteX="8dp"        tools:layout_editor_absoluteY="0dp">

        <TextView            android:id="@+id/textView2"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentTop="true"            android:layout_alignStart="@+id/editValueGiven"            android:layout_marginTop="25dp"            android:text="Enter a String"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

        <EditText            android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"            android:inputType="textFilter"            android:id="@+id/editValueGiven"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_below="@+id/textView2"            android:layout_centerHorizontal="true"            android:layout_marginTop="27dp"            android:ems="10"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

        <Button            android:id="@+id/button"            android:layout_width="279dp"            android:layout_height="wrap_content"            android:layout_alignEnd="@+id/editValueGiven"            android:layout_below="@+id/editValueGiven"            android:layout_marginTop="125dp"            android:background="@android:color/background_light"            android:onClick="check_string"            android:text="Check String"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            tools:layout_editor_absoluteX="53dp"            tools:layout_editor_absoluteY="259dp" />

        <Button            android:id="@+id/button2"            android:layout_width="281dp"            android:layout_height="51dp"            android:layout_alignStart="@+id/button"            android:layout_below="@+id/button"            android:layout_marginTop="60dp"            android:background="@android:color/background_light"            android:onClick="clear_edit_text"            android:text="Clear"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            tools:layout_editor_absoluteX="78dp"            tools:layout_editor_absoluteY="378dp" />

        <TextView            android:id="@+id/lblresult"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignStart="@+id/button"            android:layout_below="@+id/editValueGiven"            android:layout_marginTop="41dp"            android:textAppearance="@style/TextAppearance.AppCompat.Headline"            android:textColor="@android:color/background_light" />

    </RelativeLayout>

</android.support.constraint.ConstraintLayout>



DOWNLOAD SOURCE CODE HERE


DOWNLOAD APK FILE HERE