· Buka proyek Standard EXE yang baru
· Disain tampilan form seperti gambar berikut dengan
menggunakan objek Label dan TextBox dan CommandButton
Gbr 1
·
Atur Properties masing - masing kontrol seperti dibawah ini
:
Kontrol
|
Properties
|
Pengaturan
|
TextBox1
|
Name
Text
|
txt_ABC
[dikosongkan]
|
Label1
|
Name
Caption
Appearance
Border Style
|
lbl_S
[dikosongkan]
0 - Flat
1 - Fixed Single
|
Label2
|
Name
Caption
Appearance
Border Style
|
lbl_keliling
[dikosongkan]
0 - Flat
1 - Fixed Single
|
Label3
|
Name
Caption
Appearance
Border Style
|
lbl_luas
[dikosongkan]
0 - Flat
1 - Fixed Single
|
Label4
|
Name
Caption
Appearance
Border Style
|
lbl_jari2lingkdalam
[dikosongkan]
0 - Flat
1 - Fixed Single
|
Label5
|
Name
Caption
Appearance
Border Style
|
lbl_jari2lingkluar
[dikosongkan]
0 - Flat
1 - Fixed Single
|
Label6
|
Caption
|
a = b = c=
|
Label9
|
Caption
|
S
|
Label10
|
Caption
|
K
|
Label11
|
Caption
|
L
|
Label12
|
Caption
|
r
|
Label13
|
Caption
|
R
|
CommandButton1
|
Name
Caption
|
cmd_hitung
&Hitung
|
CommandButton2
|
Name
Caption
|
cmd_exit
E&xit
|
Form1
|
Name
Caption
|
Frm_Jari2LingkaranSegitiga
Program untuk
mencari Jari - Jari Lingkaran Dalam dan Lingkaran Luar Segitiga
|
· Klik menu View
=> Code, lalu kode program di
bawah ini :
Private Sub
cmd_exit_Click()
End
End Sub
Private Sub
cmd_hitung_Click()
Me.lbl_keliling.Caption = 3 *
(Val(Me.txt_ABC.Text))
Me.lbl_S.Caption = (0.5 *
Val(Me.lbl_keliling.Caption))
Me.lbl_luas.Caption = Sqr(Me.lbl_S.Caption
* ((Me.lbl_S.Caption - Val(Me.txt_ABC.Text)) * (Me.lbl_S.Caption -
Val(Me.txt_ABC.Text)) * (Me.lbl_S.Caption - Val(Me.txt_ABC.Text))))
Me.lbl_jari2lingkdalam.Caption =
Format((Me.lbl_luas.Caption / Me.lbl_S.Caption), "###,###.#0")
Me.lbl_jari2lingkluar.Caption =
Format(((Val(Me.txt_ABC.Text) ^ 3) / (4 * Me.lbl_luas.Caption)), "###,###.#0")
Me.cmd_exit.SetFocus
End Sub
Private Sub
Form_Load()
Me.cmd_hitung.Enabled
= False
End Sub
Private Sub
txt_ABC_Change()
Me.txt_ABC.MaxLength
= 4
End Sub
Private Sub
txt_ABC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13
Then
If Me.txt_ABC.Text = "" Then
MsgBox "Data tidak boleh
kosong", vbInformation + vbOKOnly, "Data Kosong"
Else
Me.cmd_hitung.Enabled = True
Me.cmd_hitung.SetFocus
End If
End If
End Sub
· Jalankan Program dengan cara menekan tombol F5 pada keyboard
atau pilih menu Run => Start
· Hasilnya ketika program dijalankan :
Gbr 2
Tidak ada komentar:
Posting Komentar
Pos kan komentar anda !