Pages

Thursday, 27 June 2013

VISUAL BASIC Pertemuan V

Pertemuan V
Hari/Tanggal    : Selasa, 02 April 2013

Pokok  Bahasan :
1). Pernyataan Bersyarat    :
                                              - If
                                              - Select

2). Pernyataan Berulang     :
                                              -For
                                              -While
                                              -Do

# Kode Berurutan                    #Kode Bersyarat
    A=20+5                                    A=20
    B=A/10                                    If (A>10) Then
    C=B-A*2                                    Print “ Unika “
       Print C                                  End If

      Contoh :
*Berapa Output Program berikut :
         Dim A As Byte
   A=50
   A=A+50
      Print A
   Output 100
* A=70
    B=10
    If (A>B) Then
       Print “ St.Thomas ”
    End If
    Output St.Thomas
* A=70
    B=50
    C=A+B-100
       Print C= 20
* Z=2*(2+5)
   R=1000-Z
   S=500
   If (5<Z) Then
       Print “ MI “
   End If  “ Tidak Dicetak “

#Bentuk If-1
      If (Kondisi) Then
        < Pernyataan >
     End If

#Bentuk If-2
      If (Kondisi) Then
        < Pernyataan >
     Else
        < Pernyataan >
      End If

        Contoh :
* A=50
    B=70
   If (A>B) Then
     C= A-B
   Else
     C=B-A
   End If
      Print C
* X=5+7
   Y=X^2+10
   R=Y-X
    If (X-10<50) Then
        Ket = “Mi Ok”
    Else
        Ket= “ Mi Yes”
    End If
        Print Ket
    Output Mi Ok

#Bentuk If – 3
     If (Kondisi ) Then
         <Pernyataan>
     Else If (Kondisi Then
         <Pernyataan>
     Else If (Kondisi Then
         <Pernyataan>
     Else If (Kondisi Then
         <Pernyataan>
     Else If (Kondisi Then
         <Pernyataan>
     End If

      Contoh :
* Gol = “V”
   If (Gol = “I”) Then
     Gapok= Rp.5000000
   Else If (Gol = “II”) Then
     Gapok= Rp.7000000
   Else If (Gol = “III”) Then
     Gapok= Rp.10000000
   Else If (Gol = “IV”) Then
     Gapok= Rp.12000000
   Else
     Gapok= Rp.15000000
    End If
        Print Gapok 

** Kode Program
    Private Sub Cmd_Hitung
       Dim Gol As String
         Dim Gapok As Long
       Gol = TxtGol.Text
         If (Gol = “I”) Then
             Gapok =Rp. 5000000
       End If
       Txt.Gapok.Text=Str(Gapok)
       End Sub



No comments :

Post a Comment