Selasa, 14 Mei 2013

Instalasi Pemrograman Android Paling Mudah

Cara paling mudah untuk melakukan instalasi pemrograman Android  adalah cukup melakukan download dan instalasi  JAva Development Kit  ( JDK) dan Android Development  Template  (ADT) Bundle saja :

Download JDK
http://www.oracle.com/technetwork/jav...

Download  ADT Bundle
http://developer.android.com/sdk/inde...

Selamat Berlatih

Kamis, 09 Mei 2013

Latihan 12 Visual Basic - Demo Event Keyboard

Latihan 12 Visual Basic - Demo Event Keyboard


'Deklarasi variabel global
Dim xpos As Single, ypos As Single

Private Sub Form_Load()
    'Pindahkan posisi roket ke tengah form
    xpos = (Me.ScaleWidth - picRoket.Width) / 2
    ypos = (Me.ScaleHeight - picRoket.Height) / 2
    picRoket.Move xpos, ypos
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    'MsgBox "Kode tombol yang ditekan : " & KeyCode
   
    'Cek tombol keyboard yang ditekan
    Select Case KeyCode
    Case vbKeyLeft  'Tombol panah kiri
        If Shift = vbCtrlMask Then
            Call RoketKeSisiKiri
        Else
            Call RoketKeKiri
        End If
    Case vbKeyRight 'Tombol panah kanan
        If Shift = vbCtrlMask Then
            Call RoketKeSisiKanan
        Else
            Call RoketKeKanan
        End If
    End Select
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    'MsgBox "Kode tombol yang dilepas : " & KeyCode
   
    'Cek tombol keyboard yang dilepas
    Select Case KeyCode
    Case vbKeyUp    'Tombol panah atas
        Call RoketKeAtas
    Case vbKeyDown  'Tombol panah bawah
        Call RoketKeBawah
    End Select
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    'MsgBox "Kode ASCII tombol yang ditekan : " & KeyAscii
   
    'Cek tombol keyboard yang ditekan
    If KeyAscii = vbKeyEscape Then  'Tombol Escape
        If MsgBox("Tutup program ?", vbQuestion + vbYesNo, _
                  Me.Caption) = vbYes Then Unload Me
    End If
End Sub

Private Sub RoketKeKiri()
    xpos = xpos - 10    'Geser ke kiri 10 pixel
    If xpos < 0 Then
        xpos = 0        'Cek bila melewati batas kiri
    End If
    picRoket.Move xpos  'Pindahkan posisi roket
End Sub

Private Sub RoketKeKanan()
    xpos = xpos + 10                                'Geser ke kanan 10 pixel
    If xpos > Me.ScaleWidth - picRoket.Width Then   'Cek bila melewati batas kanan
        xpos = Me.ScaleWidth - picRoket.Width
    End If
    picRoket.Move xpos                              'Pindahkan posisi roket
End Sub

Private Sub RoketKeAtas()
    ypos = ypos - 10            'Geser ke atas 10 pixel
    If ypos < 0 Then            'Cek bila melewati batas atas
        ypos = 0
    End If
    picRoket.Move xpos, ypos    'Pindahkan posisi roket
End Sub

Private Sub RoketKeBawah()
    ypos = ypos + 10                                 'Geser ke bawah 10 pixel
    If ypos > Me.ScaleHeight - picRoket.Height Then  'Cek bila melewati batas bawah
        ypos = Me.ScaleHeight - picRoket.Height
    End If
    picRoket.Move xpos, ypos                         'Pindahkan posisi roket
End Sub

Private Sub RoketKeSisiKiri()
    xpos = 0                    'Geser ke sisi kiri
    picRoket.Move xpos, ypos    'Pindahkan posisi roket
End Sub

Private Sub RoketKeSisiKanan()
    xpos = Me.ScaleWidth - picRoket.Width   'Geser ke sisi kanan
    picRoket.Move xpos, ypos                'Pindahkan posisi roket
End Sub

Latihan 11 Visual Basic - Procedure Test

Latihan 11 Visual Basic - Procedure Test


 Dim Harga As Currency, Total As Currency

Private Sub TulisTeks(teks As String, Optional warna As ColorConstants = vbMagenta)
    With Label1
        .Caption = teks
        .ForeColor = warna
    End With
End Sub

Private Function JumlahAngka() As String
    Dim angka1 As String, angka2 As String
    Dim hasil As Single
   
    angka1 = InputBox("Tulis angka 1 :", "Hitung Angka")
    angka2 = InputBox("Tulis angka 2 :", "Hitung Angka")
   
    If angka1 <> "" And angka2 <> "" Then
        hasil = CSng(angka1) + CSng(angka2)
        JumlahAngka = CStr(hasil)
    End If
End Function

Private Sub HitungDiskon(ByVal HargaAwal As Currency, Diskon As Single)
    HargaAwal = HargaAwal * (1 - Diskon)
    Total = CCur(HargaAwal)
End Sub


Private Sub Label1_DblClick()
    Call TulisTeks("Hai", vbBlue)
End Sub

Private Sub Command1_Click()
    'Call TulisTeks("Hallo", vbRed)
    Call TulisTeks("Hallo")
End Sub

Private Sub Command2_Click()
    Label1.Caption = "Jumlah = " & JumlahAngka()
End Sub

Private Sub Command3_Click()
    Harga = 10000
    Total = 0
    Call HitungDiskon(Harga, 0.1)
    MsgBox "Harga " & Harga & " setelah diskon 10% menjadi " & Total
End Sub



Latihan 10 Visual Basic - Error Handle

Latihan 10 Visual Basic - Error Handle


Private Sub Command1_Click()

    Dim FileName As String
    Dim ErrMsg As String
    Dim Ask As VbMsgBoxResult
 
    On Error GoTo AdaError

Awal:
    Image1.Picture = Nothing
    FileName = InputBox("Ketikkan path dan nama file gambar :", "Open Picture File", FileName)
    If FileName <> "" Then
        Image1.Picture = LoadPicture(FileName)
    End If
    Exit Sub
 
AdaError:
    Select Case Err.Number
    Case 53
        ErrMsg = "File [" & FileName & "] tidak ada !"
    Case 71
        ErrMsg = "Disket belum dimasukkan !"
    Case Else
        ErrMsg = Err.Description
    End Select
 
    Ask = MsgBox(ErrMsg, vbCritical + vbRetryCancel, Me.Caption)
 
    Select Case Ask
    Case vbRetry
        If Err.Number = 53 Then Resume Awal Else Resume
    Case vbCancel
        Resume Next
    End Select
End Sub

Latihan 9 Visual Basic - Aplikasi Kalkulator

Latihan 9 Visual Basic  - Aplikasi Kalkulator


Dim angka(1 To 2) As Single

Dim operator As String

Private Sub cmdAngka_Click(Index As Integer)
    Text1.Text = Text1.Text & cmdAngka(Index).Caption
End Sub

Private Sub cmdHapus_Click()
    Text1.Text = ""
End Sub

Private Sub cmdOperator_Click(Index As Integer)
    If Text1.Text = "" Then Exit Sub
 
    angka(1) = CSng(Text1.Text)
    operator = cmdOperator(Index).Caption
    Text1.Text = ""
End Sub

Private Sub cmdHitung_Click()
    Dim hasil As Single
     
    If Text1.Text = "" Then Exit Sub
 
    angka(2) = CSng(Text1.Text)
 
    Select Case operator
    Case "+"
        hasil = angka(1) + angka(2)
    Case "-"
        hasil = angka(1) - angka(2)
    Case "*"
        hasil = angka(1) * angka(2)
    Case "/"
        hasil = angka(1) / angka(2)
    End Select
 
    Text1.Text = hasil
End Sub


 
Design by Wordpress Theme Template Blog Free | Bloggerized by Free Blogger Templates | coupon codes