Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Thursday, December 27, 2012




I made a simple program that opens a .txt file and insert all text into the texbox you can download the source code below. I added some comment for you to understand how the code works and flows throughout the program.

DOWNLOAD LINK: http://adf.ly/GaIpP

Saturday, December 15, 2012



here is my tutorial how to create a fibonacci series using for loop in visual basic . net please comment below if you some questions and clarifications.


'the code below is for checking if the txtSequence is blank
        ' if the sequence is blank a message box will popup
        If txtSequence.Text = "" Then
            MsgBox("Please enter a sequence")
            txtSequence.Focus()

            'this code below will check if the txtSequence text is digit
            'if the txtSequence is not a digit then a message box will pop up
        ElseIf Not Char.IsDigit(txtSequence.Text) Then
            MsgBox("Please enter a number")
            txtSequence.Clear()
            txtSequence.Focus()

        Else
            Dim sequence As Integer = txtSequence.Text
            Dim firstnum As Double = 0
            Dim secondnum As Double = 1
            Dim thirdnum As Double

            'the code below will output the firstnum and the second number
            txtAnswer.Text = firstnum & ", " & secondnum & ", "

            'this code is called for loop it will loop until sequence is equal to
            'after every loop the value of sequence will decrease by 1
            For ctr = 0 To sequence - 1
                'the code below will add the firstnumber and the second number
                'the sum of both number will be placed at the variable thirdnum
                thirdnum = firstnum + secondnum
                txtAnswer.Text += thirdnum & ", "
                'now the value of the second number will be placed at the variable firstnum
                firstnum = secondnum
                'now the value of the third number will be placed at  the variable secondnum
                secondnum = thirdnum
                'after executing the commands it will go back at the for loop to check if the value of sequence is zero
                'if the value of sequence is not zero it will continue the for loop and the value of sequence will decrease by 1
            Next

        End If

Thursday, December 13, 2012


here is my simple calculator for beginners. the codes that I used in this program is so simple so beginners can easily understand how it works.

the btnAdd is for addition.
the btnSub is for subtraction.
the btnMul is for multiplication.
the btnDiv is for division.

for addition i used. cDbl is for converting the textbox file into double so it can accept numbers with decimal point.


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        txtResult.Text = CDbl(txtFirstNum.Text) + CDbl(txtSecondNum.Text)
  End Sub

for subtraction.


Private Sub btnSub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSub.Click
        txtResult.Text = CDbl(txtFirstNum.Text) - CDbl(txtSecondNum.Text)
    End Sub


for multiplication.


Private Sub btnMul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMul.Click
        txtResult.Text = CDbl(txtFirstNum.Text) * CDbl(txtSecondNum.Text)
    End Sub


for subtraction


Private Sub btnDiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDiv.Click
        txtResult.Text = CDbl(txtFirstNum.Text) / CDbl(txtSecondNum.Text)
    End Sub





Wednesday, December 12, 2012



I got bored so i did a simple php program that generates a centered triangle with table for every spaces and stars. I used a 4 for loops.

First for loops is for the size of the triangle
Second for loops is for the spaces at the left side.
Third for loop is for the stars.
Fourth for loop is for the spaces at the right side.


if you want to change the size just change the value of variable $size


<?php
$size = 5;
echo "<table border = '1'> <tr>";
for ($i = 0; $i < $size; $i++)
        {
            $stars = 1 + 2 * ($i);
            $space = $size - $i;
            for ($j = 0; $j < $space; $j++)
            {
                echo("<td>&nbsp;&nbsp;</td>");
            }
           
            for ($k = 0; $k < $stars; $k++)
            {
                echo "<td>*</td>";
            }
$stars = 1 + 2 * ($i);
            $space = $size - $i;
            for ($j = 0; $j < $space; $j++)
            {
                echo("<td>&nbsp;&nbsp;</td>");
            }

            echo("</tr>");
        }
echo("</table>")
?>
Subscribe to RSS Feed Follow me on Twitter!