Monthly Archives: July 2010

Making Round Application

This application is an example for accounting in a program. It means that this is our 1st program  that is able to do program as a basic to make more complicated program. In this program you have to prepare :

-Label

Properties :

Text :Radius :

-Label

Properties :

Text :Surface :

-Label

Properties :

Text :Circumference :

-Textbox

Properties :

Name :txtradius:

-Textbox

Properties :

Name :txtsurface

-Textbox

Properties :

Name :txtcircum

-Button

Properties :

Name :btcount

Text :Count

-Button

Properties :

Name :btreset

Text :Reset

Here is the appearance :

Then,  Click twice into btcount , and type source code below :


Public Class Form1

Dim r, surface, circum As Double

Const phi = 3.14

Private Sub btcount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcount.Click

r = Val(CDbl(txtradius.Text))

surface = phi * r ^ 2

circum = 2 * phi * r

txtsurface.Text = surface

txtcircum.Text = circum

End Sub

Also type Click twice into btreset, and tpe source code below :


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btreset.Click

txtradius.Text = ""

txtsurface.Text = ""

txtcircum.Text = ""

txtradius.Focus()

End Sub

Now, you’ll need to run your program (press F5)

Advertisements

Making Value Converter Into Letter

  1. Create new  project
  2. Prepare the items :

Label

Properties :

Text :value

 

textbox

Properties :

name :txtvalue

 

button

Properties :

Text :convert

Name:btconvert

 

Label2

  1. Click twice into btconvert ,  Type source code below :

Public Class Form1

Dim a As Integer

Dim b As String

Private Sub btconvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btconvert.Click

a = Val(CInt(txtvalue.Text))

If a > 80 And a <= 100 Then

b = "A"

ElseIf a > 70 And a <= 80 Then

b = "B"

ElseIf a > 60 And a <= 70 Then

b = "C"

ElseIf a > 50 And a <= 60 Then

b = "D"

ElseIf a > 0 And a <= 50 Then

b = "E"

Else

b = "OUT OF RANGE"

End If

Label2.Text = b

End Sub

End Class

4.   Run the program (F5)

Creating Web Browser by using Microsoft Visual Basic 2008 Express Edition

Nowadays, there is an issue that some web browsers work slowly on low bandwidth , moreover in low specification computer. Therefore, there are so many new web browsers which is created to fulfill that requirements. For example chromium web browser which is created by google team. But, sometimes it doesn’t satisfy the user. So that, I’m gonna tell you how to make your own web browser which is faster than the other web browser.

Below is the way :

1.  Create new project

 

 

 

 

 

 

 

 

 

 

 

 

 

2.  In order to make the window of your program became larger you can pull main window of your program (streching)

    3.  Prepare the appearance and items that is needed :

    Label

    Properties

    Text          : Address

     

    Textbox

    Properties

    Name       : Txtaddress

     

    Web browser

    Properties

    Name       : Browser

     

    Button

      Properties

      Name       : btngo

      text           :Go

       

      Put all of them into main window, Such as this appearance

      Double click into btngo, then type this source code :

      
      Public Class Form1
      
      Private Sub btngo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngo.Click
      
      browser.Navigate(txtaddress.Text)
      
      End Sub
      
      End Class
      
      

      Now, let’s run our 1st program you can press F5 or debug -> start debuggin

      In text box input the url that you want to browse , make sure your internet connection is connected, unless you can try using localhost in browser (by using local web server)

      Here is example when the web browser is connected

      Microsoft Visual Basic 2008 Express Edition

      Visual Basic is a popular programming language because it’s easy in using and also has many complete library for building and developing a program. Microsoft Visual Basic 2008 express Edition is the next version from the Visual Basic 2005. And, it has adopted dotnet framework 3.5 .

      Start using Microsoft Visual Basic 2008 Express Edition

      Visual Basic 2008 has been package in application Microsoft Visual Studio 2008. When installation, you can choose which one kind of programming language or you can install all of them involve visual c# and visual c++.

      Below is the way to use VB 2008 :

      1. Click Start -> Microsoft Visual Basic 2008 Express Edition

      1. Choose create project.

      1. Choose windows form application  -> ok
      2. Now , you can start to make your own program easily

      Algorithm & programming part V (Data Structure)

      Huh….guys, In this meeting i’m gonna share with you about a little bit of my experience. Some hours ago, i’ve typed this articles until finish. Then my friend invite me to go to campus. A few minutes later, I resume my computer and reopen my articles. You know what happen ??? the data is dissapear, so that i’ve to write type it again. Hmm…. that’s unpleasure experience.

      Actually 2 days ago the holiday has been begun for my major, but unfortunatelly I still have so many kinds of activities such as regional english seminar. Alhamdulillah the seminar run well. Guys , after the seminar attended, I plan to go home immediately but the leader of my organization said to me that “Bro , don’t go home, we’ll go to Pare”. Wow Kediri pare, Directly I know the purpose which is besides enjoying holiday, we’re gonna take english course . So, if you’re interested to join with us,you can contact me through facebook,okay…

      Well, actually now we were in Data Structure topic. Data Structure is a fundamental item for a programmer to master. In data Structure we have so many topics . Below is the list :

      1. array
      2. Struct/ record
      3. Union (only in C)
      4. Pointer and static Variable
      5. stack
      6. Queue
      7. linked List
      8. Sorting
      9. Searching
      10. Tree
      11. Graph

      That’s all the subtopics for data structure. The first we’re gonna talk about Array. Array is a finite ordered set of homogeneous elements. It means that , Array contains of a group of elements which has same type and. The amount of elements are determined and arranged. Array has 3 types : 1st is one dimension array, 2nd is two dimension array , 3rd is three dimension array. All of them have their own function. The 1st type is usually used for displaying common data. The 2nd type is usually used for displaying matrix and point location. The last type is usually used for displaying point location of 3 dimension object.

      Below is examples for each types :

      example program array 1 dimension :

      PASCAL

      program array_1_dimension;
      uses crt;
      var
      a:array [1..10]of integer;
      b,c:integer;
      begin
      write('input a number = ');read(b);
      {input data}
       for c:=1 to b do
       begin
       write('index[',c,']=');read(a[c]);
       end;
      {display data}
       for c:=1 to b do
       begin
       writeln(a[c]);
       end;
      end.
      
      

      C

      #include<stdio.h>
      
      int main(){
      int c[10];
      int a,b;
       printf("input a number = ");scanf("%d",&a);
       //input
       for (b=1; b<=a;b++){
       printf("index[%d] = ",b);scanf("%d",&c[b]);
       }
       //display
       for (b=1; b<=a;b++){
       printf("%d\n",c[b]);
       }
      }
      
      

      example array 2 dimension (Matrix) :

      PASCAL

      program array_2_dimension(matrix);
      uses crt;
      var
      mat:array [1..10,1..10]of integer;
      a,b,row,coloumn:integer;
      begin
      write('input a row = ');read(row);
      write('input a coloumn = ');read(coloumn);
      {input data}
       for a:=1 to row do
       begin
       for b:=1 to coloumn do
       begin
       write('index[',a,',',b,']=');read(mat[a,b]);
       end;
       end;
      {display data}
       for a:=1 to row do
       begin
       for b:=1 to coloumn do
       begin
       write(mat[a,b]:3);
       end;
       writeln;
       end;
      end.
      
      
      

      C

      #include<stdio.h>
      
      int main(){
      int mat[10][10],a,b,row,coloumn;
       printf("please input a row = ");scanf("%d",&row);
       printf("please input a coloumn = ");scanf("%d",&coloumn);
       for (a=1;a<=row;a++)    {
       for (b=1;b<=coloumn;b++){
       printf("index[%d,%d]=",a,b);scanf("%d",&mat[a][b]);
       }
       }
       for (a=1;a<=row;a++)    {
       for (b=1;b<=coloumn;b++){
       printf("%d  ",mat[a][b]);
       }
       printf("\n");
       }
      }
      
      

      example for 3 dimensions array :

      PASCAL

      program array_3_dimension(matrix);
      uses crt;
      var
      mat:array [1..10,1..10,1..10]of integer;
      a,b,c,x,y,z:integer;
      begin
      write('input x coordinate = ');read(x);
      write('input y coordinate= ');read(y);
      write('input z coordinate= ');read(z);
      {input data}
       for a:=1 to x do
       begin
       for b:=1 to y do
       begin
       for c:=1 to z do
       begin
       write('index[',a,',',b,',',c,']=');read(mat[a,b,c]);
       end;
       end;
       end;
      {display data}
       for a:=1 to x do
       begin
       for b:=1 to y do
       begin
       for c:=1 to z do
       begin
       write(mat[a,b,c]:3);
       end;
       writeln;
       end;
       writeln;
       end;
       writeln;
      end.
      
      
      

      C

      #include<stdio.h>
      
      int main(){
      int mat[10][10][10],a,b,c,x,y,z;
       printf("please input x coordinate = ");scanf("%d",&x);
       printf("please input y coordinate = ");scanf("%d",&y);
       printf("please input z coordinate = ");scanf("%d",&z);
       for (a=1;a<=x;a++){
       for (b=1;b<=y;b++){
       for (c=1;c<=z;c++){
       printf("index[%d,%d,%d]=",a,b,c);scanf("%d",&mat[a][b][c]);
       }
       }
       }
      
       for (a=1;a<=x;a++){
       for (b=1;b<=y;b++){
       for (c=1;c<=z;c++){
       printf("%d  ",mat[a][b][c]);
       }
       printf("\n");
       }
       printf("\n");
       }
      }
      
      
      

      Algorithm & programming part IV

      Hhmm……., in this part we’re gonna talk about procedure and function. Procedure and function is used to make program can be easier to be read and understood. Not only that, procedure and function can be used to make program easier to be analyzed weather there is mistake or not. So, when there is long codes of program, it can be separated into small parts as procedure or function. And, procedure and function will make you easy to find out error and fix it (error handling). Well, actually there are differences between procedure and function. Procedure doesn’t has return value. However, function has it. Not only that, pascal has procedure and function. But, C doesn’t have it . On the other side, function in C able to creat return value or not. Depend on the type of function. Pascal has parameter for procedure and function and C is either.

      Below is some examples the use of function and procedure by parameter or not

      example program without parameter :

      PASCAL

      program table;
      uses crt;
      
      procedure appearance;
      begin
      writeln('this program is made for procedure without parameter');
      writeln('this program only contains of appearance and main program');
      writeln('this program will use two procedures');
      writeln('this 1st procedure for apperance ');
      writeln('the 2nd procedure for main program ');
      writeln('start ');
      writeln('press ENTER ');
      readln;
      end;
      
      procedure main;
      var
      a:byte;
      begin
      for a:=1 to 10 do
      writeln('ACHMAD FAUZI');
      end;
      
      var
      a:byte;
      begin
      appearance;
      main;
      end.
      
      

      C

      #include <stdio.h>
      #include <string.h>
      
      void appearance();
      void primary();
      
      int main(){
      appearance();
      primary();
      }
      void appearance(){
      printf("this program is made for procedure without parameter\n");
      printf("this program only contains of appearance and main program\n");
      printf("this program will use two procedures\n");
      printf("this 1st procedure for apperance \n");
      printf("the 2nd procedure for main program\n");
      printf("start\n");
      printf("press ENTER \n");
      getchar();
      }
      void primary(){
      int a;
      for (a=1;a<=10;a++)
      printf("ACHMAD FAUZI\n");
      }
      
      

      example program by using input parameter :

      Pascal

      PASCAL
      program sum;
      uses crt;
      var
      a:integer;
      
      procedure add(x:integer);
      var
      b,c,d:integer;
      begin
      d:=0;
       for b:=1 to x do
       begin
       write('index[',b,']=');read(c);
       d:=d+c;
       end;
      writeln('total = ',d);
      end;
      
      begin
      write('please input a number =');read(a);
      add(a);
      end.
      
      

      C

      #include<stdio.h>
      
      void out();
      int main(){
      out();
      }
      
      void out(){
      int a,b,c,d;
      printf("input a number = ");scanf("%d",&a);
      d=0;
       for (b=1;b<=a;b++){
       printf("index[%d] :",b);scanf("%d",&c);
       d+=c;
       }
      printf("total = %d\n",d);
      };
      
      

      example program by using output parameter :

      PASCAL

      program average_by_output_parameter;
      uses crt;
      var
      b,c,d,e:integer;
      a:real;
      procedure ave(var a:real);
      begin
      e:=0;
      write('input a number = ');read(b);
       for c:=1 to b do
       begin
       write('index[',c,']=');read(d);
       e:=e+d;
       end;
      a:=e/b;
      end;
      
      begin
      ave(a);
      writeln('average = ',a:2:2);
      end.
      
      
      

      C

      #include<stdio.h>
      
      int out (int b,int d);
      
      
      void main(){
      int b,d;
      float a;
      a=out (b,d);
      printf("average = %2.2f\n",a);
      }
      
      
      int out (int b,int d){
      int c,e;
      float a;
      e=0;
      
      printf("input a number  =");scanf("%d",&b);
       for (c=1;c<=b;c++){
       printf("index[%d] = ",c);scanf("%d",&d);
       e+=d;
       }
      a=e/b;
      return (a);
      }
      
      
      

      example program by using input and output parameter :

      PASCAL

      program average_by_output_and_output_parameter;
      uses crt;
      var
      b:integer;
      a:real;
      
      procedure ave(b:integer ;var a:real);
      var
      c,d,e:integer;
      begin
      e:=0;
       for c:=1 to b do
       begin
       write('index[',c,']=');read(d);
       e:=e+d;
       end;
      a:=e/b;
      end;
      
      begin
      write('input a number = ');read(b);
      ave(b,a);
      writeln('average = ',a:2:2);
      end.
      
      

      C

      #include <stdio.h>
      
      int jalan(int a);
      
      void main(){
      int a;
      float e;
      printf("input a number = ");scanf("%d",&a);
      e=jalan(a);
      printf("average = %2.2f\n",e);
      }
      
      int jalan(int a){
      int b,c,d;
      float e;
      d=0;
       for (b=1;b<=a;b++){
       printf("index[%d]",b);scanf("%d",&c);
       d+=c;
       }
      e=d/a;
      return (e);
      } 10.c
      
      
      

      Algorithm & programming part III

      Alhamdulillah, in this part , I feel so glad because I’ve already build the appearance for my old weblog. In this part we’re gonna discuss about looping. Looping is a repeated statements based on centain condition which is determined by the programmer.Pascal and C have same models of looping. Below is models of looping in Pascal and C

      Model Pascal C
      1. For For [condition] to [condition] do…[action]…. For (condition;conditon;terms){…….[action]………..

      }

      2. While While [condition] dobegin

      …..[action]…………..

      end;

      While (conditon){……[action]…………….

      }

      3. Do …while repeat….until Repeat[action]

      until

      [condition]

      Do{

      [action]

      }

      while (condition)

      Looping used to make programmer think harder, because in creating a program, looping must be tried repeatedly, in order to get match value. Moreover nested loop. Nested loop means looping inside looping.Looping is separated into descending and ascending loop.

      Example (program to count average value):

      PASCAL

       

      program average;
      uses crt;
      var
      a,b,c,d:integer;
      e:real;
      begin
      d:=0;
      write('input sum of number :');read(a);
       for b:=1 to a do
       begin
       write('index[',b,']=');read(c);
       d:=d+c;
       end;
      e:=d/a;
      writeln('average = ',e:2:2);
      end.
      

      C

       

      #include <stdio.h>
      
      int main(){
      int a,b,c,d;
      float e;
      d=0;
      printf("input sum of a number = ");scanf("%d",&a);
       for (b=1;b<=a;b++){
       printf("index[%d]=",b);scanf("%d",&c);
       d+=c;
       }
      e=d/a;
      printf("average=%2.2f\n",e);
      }
      

      PASCAL

      program average_by_while;
      uses crt;
      var
      a,b,c,d:integer;
      e:real;
      begin
      d:=0;
      write('input sum of number :');read(a);
      b:=1;
       while b<=a do
       begin
       write('index[',b,']=');read(c);
       d:=d+c;
       b:=b+1;
       end;
      
       e:=d/a;
       writeln('average = ',e:2:2);
      
      end.
      
      

      C

      #include <stdio.h>
      
      int main(){
      int a,b,c,d;
      float e;
      d=0;
      printf("input sum of a number = ");scanf("%d",&a);
      b=1;
       while (b<=a){
       printf("index[%d]=",b);scanf("%d",&c);
       d+=c;
       b+=1;
       }
      
      e=d/a;
      printf("average=%2.2f\n",e);
      }
      
      

      PASCAL

      program average_by_repeat;
      uses crt;
      var
      a,b,c,d:integer;
      e:real;
      begin
      d:=0;
      write('input sum of number :');read(a);
      b:=0;
       repeat
       begin
       write('index[',b,']=');read(c);
       d:=d+c;
       b:=b+1;
       end;
       until b=a;
      
      e:=d/a;
      writeln('average=',e:2:2);
      
      end.
      
      

      C

      #include <stdio.h>
      
      int main(){
      int a,b,c,d;
      float e;
      d=0;
      printf("input sum of a number = ");scanf("%d",&a);
      b=1;
       do{
       printf("index[%d]=",b);scanf("%d",&c);
       d+=c;
       b+=1;
       }
       while(b<=a);
      
      e=d/a;
      printf("average=%2.2f\n",e);
      }
      
      

      Okay, that’s all example for models of looping in PASCAL and C . So, have fun with your algorithm…