Visual Basic Part 3

download Visual Basic Part 3

of 4

Transcript of Visual Basic Part 3

  • 8/8/2019 Visual Basic Part 3

    1/4

    Latihan 6.

    Buat Design Form Sebagai berikut:

    Object Propertis SettingName frmhitung

    Caption ..::Program Keenam::..Form1

    StartUpPostion 2 - CenterScreen

    Name txtpanjang

    TextBox1 Text Tulisan text1 di hapus

    Name txtlebarTextBox2

    Text Tulisan text2 di hapus

    Name txtluasTextBox3

    Text Tulisan text3 di hapus

    Name txtkelTextBox4

    Text Tulisan text3 di hapus

    Name cmdhitungCommand

    Button1 Caption &Hitung

    Name cmdlagiCommand

    Button2 Caption &Lagi

    Name cmdkeluarCommandButton3 Caption &Keluar

    Frame1 Caption INPUT

    Frame2 Caption Hasil

  • 8/8/2019 Visual Basic Part 3

    2/4

    Private Sub cmdhitung_Click()Dim p, l, luas, kel As Integer

    p = Val(txtpanjang.Text)

    l = Val(txtlebar.Text)

    luas = p * l

    kel = 2 * (p + l)

    txtluas.Text = luas

    txtkel.Text = kel

    End Sub

    Private Sub cmdkeluar_Click()End

    End Sub

    Private Sub cmdlagi_Click()txtpanjang.Text = ""

    txtlebar.Text = ""

    txtluas.Text = ""

    txtkel.Text = ""

    txtpanjang.SetFocus

    End Sub

    Private Sub txtpanjang_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then

    txtlebar.SetFocus

    End If

    End Sub

  • 8/8/2019 Visual Basic Part 3

    3/4

    Latihan 7

    Buat Design Form Sebagai berikut:

    Obj ect Propertis SettingName frmwarna

    Caption ..::Program

    Ketujuh::..Form1

    StartUpPostion 2 - CenterScreen

    Name optmerahOptionButoon1

    Caption MERAH

    Name optbiru

    OptionButoon2 Caption BIRU

    Name optkuningOptionButoon3

    Caption KUNING

    Name opthitamOptionButoon4

    Caption HITAM

    Name optputih

    OptionButoon5 Caption PUTIH

    Name opthijauOptionButoon6

    Caption HIJAU

    Name optunguOptionButoon7

    Caption UNGU

    Untuk ukuran huruf option nya juga sama tapi

    berbeda nama & captionFrame1 Caption Warna Huruf

    Frame2 Caption Warna Background

    Frame3 Caption Ukuran Huruf

  • 8/8/2019 Visual Basic Part 3

    4/4

    Private Sub opt8_Click()Label1.FontSize = 8

    End Sub

    Private Sub opt14_Click()Label1.FontSize = 14

    End Sub

    Private Sub opt10_Click()Label1.FontSize = 10

    End Sub

    Private Sub opt12_Click()Label1.FontSize = 12

    End Sub

    Private Sub optbiru_Click()Label1.ForeColor = vbBlue

    End Sub

    Private Sub opthijau_Click()Me.BackColor = vbGreen

    Label1.BackStyle = 0End Sub

    Private Sub opthitam_Click()Label1.ForeColor = vbBlack

    End Sub

    Private Sub optkuning_Click()Label1.ForeColor = vbYellow

    End Sub

    Private Sub optmerah_Click()Label1.ForeColor = vbRed

    End Sub

    Private Sub optputih_Click()

    Me.BackColor = vbWhite

    Label1.BackStyle = 0

    End Sub

    Private Sub optungu_Click()Me.BackColor = vbMagenta

    Label1.BackStyle = 0

    End Sub