Friday, April 14, 2017

Square a Number Using Visual Basic NET


In this article I would like to share with you guys a simple program that will ask the user to give a number and then our program will convert the given number into its square number equivalent. I wrote this code using Microsoft Visual Basic NET 2013. I added an error checking for empty text box value.  I hope you will find my work useful thank you very much.

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

Public Class Form1
    Function Square(ByVal y As Integer) As Integer
        Return y ^ 2
    End Function

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a, solve As Integer
        Dim b As String

        a = Val(TextBox1.Text)

        solve = Square(a)

        If TextBox1.Text = "" Then
            MessageBox.Show("Sorry can't be empty.")
            TextBox1.Focus()

        Else
            Label2.Text = "The square value of " & a & " is " & solve & "."
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class



Square a Number in Turbo Pascal

Here is a sample program that will ask the user to give a number and then the program will convert the given number into it's square number equivalent using Pascal as our programming language. 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

Program Square_Solver;

Uses WinCrt;

Var a : integer;

Begin

  Clrscr;
  Write('Square Value Converter in Pascal');
  Writeln;
  Writeln;
  Write('Give a Number : ');
  Readln(a);
  Writeln;
  Write('The square value of ' ,a, ' is ' , sqr(a),'.');
  Writeln;
  Writeln;
  Write('End of Program');
  Readln;
End.



Monday, April 10, 2017

Sum of Three Numbers in Visual Basic

Here is a program that will ask the user to give three numbers and then it will compute the total sum of the three numbers given by our user. I am using Visual Basic 5 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

Private Sub Command1_Click()
Dim sum As Integer

a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)

sum = (a + b + c)

Text4.Text = sum

End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub



Difference of Two Numbers in Ruby

A program that I wrote using Ruby programming language that will ask the user to give two numbers and then our program will find the difference of the two numbers. The code is very simple 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

print "\n\n";
print "Difference of Two Numbers in Ruby"
print "\n\n";
print "enter number 1 : ";
val1 = gets;
print "enter number 2 : ";
val2 = gets;

val1 = val1.to_i
val2 = val2.to_i

difference = difference.to_i

difference = (val1 -val2)

print "\n\n";
puts "The difference of #{val1} and #{val2} is #{difference}.";
print "\n\n";
print "End of Program";
print "\n\n";




Sunday, April 9, 2017

Hello World in Ruby

A very simple program that I wrote using Ruby programming language to demonstrate the hello world program. I am just a beginner in ruby programming. 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

puts "\n"
puts 'Hello World in Ruby by Jake R. Pomperada'
puts "\n\n"
puts "End of Program"


Fibonacci Number Sequence in Visual Basic NET

A simple program that I wrote using Visual Basic NET to ask the user to give a number and then our program will generate the corresponding fibonacci number sequence based on the given number by our user. 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

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Integer = 0
        Dim i As Integer
        Dim b As Integer = 1
        Dim fib As Integer
        ListView1.Items.Add(1)
        i = Val(TextBox1.Text)

        ListView1.Items.Add(1)
        Do
            fib = a + b
            a = b
            b = fib
            ListView1.Items.Add(fib)
            i = i + 1
        Loop While fib < i

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
        ListView1.Clear()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class



Armstrong Number Checker in Visual Basic NET

Here is a sample program that will ask the user to give a number and then the program will check and determine if the given number is armstrong or not the code is very easy to understand and use. 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

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim n, sum, t, r As String

        n = Val(TextBox1.Text)

        sum = 0
        t = n
        While n <> 0
            r = n Mod 10
            sum += Math.Pow(r, 3)
            n = n \ 10

        End While
        If sum = t Then
            Label2.Text = "The number " & t.ToString & " is a Armstrong Number."
        Else
            Label2.Text = "The number " & t.ToString + " is NOT an Armstrong Number."
        End If

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class


Reverse a Number Checker in Visual Basic NET

Here is a sample program that I wrote using Visual Basic NET to ask the user to give a number and then our program will reverse the arrangement of the number. 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 Listing

Program Listing

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim n As String

        n = TextBox1.Text
        Label2.Text = "The reverse arrangement of the number is " & n.AsEnumerable.Reverse.ToArray & "."

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class



Perfect Number Checker in Visual Basic NET

A very simple program that I wrote using Visual Basic NET to ask the user to give a number and then the program will check if the given number is a PERFECT number or NOT a PERFECT number. The code is very easy to understand and use. 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

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim n, sum, p, r As Integer

        n = Val(TextBox1.Text)
        p = 1
        sum = 0
        While p <= n \ 2
            r = n Mod p
            If r = 0 Then
                sum += p
            End If
            p += 1
        End While

        If sum = n Then
            Label2.Text = "The number " & n & " is a PERFECT Number."
        Else
            Label2.Text = "The number " & n & " is NOT a PERFECT Number."
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class






Prime Number in Visual Basic NET

Here is a sample program that I wrote using Visual Basic NET to ask the user to give a number and then our program will check and determine if the given number is a prime number or not a prime number. 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

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a, b As Integer
        Dim t As Boolean
        a = Val(TextBox1.Text)
        t = True
        For b = 2 To (a - 1)
            If a Mod b = 0 Then
                t = False
                Exit For
            End If
        Next b
        If t Then
            Label2.Text = "The number " & a & " is a PRIME Number."
        Else
            Label2.Text = "The number " & a & " is NOT a PRIME Number."
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class


Odd and Even Number in Visual Basic NET

A very simple program that I wrote using Visual Basic NET to ask the user to give a number and then the program will check if the given number is an EVEN or ODD number. The code is very easy to understand and use. 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

Public Class Form1

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim val_me As Integer
        Dim isEven As Boolean
        val_me = Val(TextBox1.Text)
        If val_me Mod 2 = 0 Then
            isEven = True
            Label2.Text = "The number " & " " & val_me & " is an EVEN number" & "."
        Else
            Label2.Text = "The number " & " " & val_me & " " & "is an ODD number" & "."
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class


Friday, April 7, 2017

Positive and Negative Number Checker in Visual Basic NET

Here is a sample program that will ask the user to give a number and then our program will determine and check if the given number is a positive or negative number. The code is written in Visual Basic NET I am using Visual Studio 2013 Ultimate Edition in writing this 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
 
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Val(TextBox1.Text) >= 0 Then
            Label2.Text = "The given nunber " & TextBox1.Text & " is a POSITIVE NUMBER" & "."
        Else
            Label2.Text = "The given nunber " & TextBox1.Text & " is a NEGATIVE NUMBER" & "."
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class
 


 

Sum of Even Numbers in Visual Basic NET

Hi there in this article I would like to share with you a sample program that will ask the user to give a number and then our program will compute the total sum of all the even numbers in the given number value by our user using Visual Basic NET. The code is very simple 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

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim sum As Integer
        If Val(TextBox1.Text) < 2 Then
            MsgBox("Invalid value !!! Try Again", vbCritical)
        Else
            For a = 2 To Val(TextBox1.Text) Step 2
                sum = sum + a
            Next a
            Label2.Text = "The sum of all even numbers from 1 to " & TextBox1.Text & ": " & sum & "."
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub
End Class