·
Buka proyek Standard EXE yang baru
·
Disain tampilan form seperti gambar berikut
dengan menggunakan objek Label dan TextBox dan Line
Gbr 1
·
Atur Properties masing - masing kontrol seperti
dibawah ini :
Kontrol
|
Properties
|
Pengaturan
|
TextBox1
|
Name
Text
Font
ForeColor
BackColor
|
txt_angka
(dikosongkan)
MS Sans Serif, Bold,
10
&H00000080&
&H0080C0FF&
|
Label1
|
Caption
Font
ForeColor
BackColor
|
Angka Romawi (Roman
Numeral)
MS Sans Serif, Bold,
14
&H00FF0000&
&H0080FF80&
|
Label2
|
Caption
Font
ForeColor
BackColor
|
1
MS Sans Serif, Bold,
12
&H0080FF80&
&H0080FF80&
|
Label3
|
Caption
Font
ForeColor
BackColor
|
5
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label4
|
Caption
Font
ForeColor
BackColor
|
10
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label5
|
Caption
Font
ForeColor
BackColor
|
50
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label6
|
Caption
Font
ForeColor
BackColor
|
100
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label7
|
Caption
Font
ForeColor
BackColor
|
500
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label8
|
Caption
Font
ForeColor
BackColor
|
1000
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label9
|
Caption
Font
ForeColor
BackColor
|
I
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label10
|
Caption
Font
ForeColor
BackColor
|
V
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label11
|
Caption
Font
ForeColor
BackColor
|
X
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label12
|
Caption
Font
ForeColor
BackColor
|
L
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label13
|
Caption
Font
ForeColor
BackColor
|
C
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label14
|
Caption
Font
ForeColor
BackColor
|
D
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label15
|
Caption
Font
ForeColor
BackColor
|
M
MS Sans Serif, Bold,
12
&H00FF0000&
&H0080FF80&
|
Label16
|
Caption
Font
ForeColor
BackColor
|
Angka maximum yang
dapat dikonversi = 3999
MS Sans Serif, Bold,
10
&H00404000&
&H0080FF80&
|
Label17
|
Caption
Font
ForeColor
BackColor
|
Angka Latin
MS Sans Serif, Bold,
10
&H00000080&
&H0080FF80&
|
Label18
|
Caption
Font
ForeColor
BackColor
|
Angka Romawi
MS Sans Serif, Bold,
10
&H00000080&
&H0080FF80&
|
Label19
|
Name
Caption
Font
ForeColor
BackColor
|
lbl_terbilang
(dikosongkan)
Palatino Linotype,
Bold, 12
&H00000080&
&H0080C0FF&
|
Line1 s/d Line11
|
BorderColor
BorderWidth
|
&H00404000&
2
|
Line12
|
BorderColor
BorderWidth
|
&H00FF0000&
2
|
Line13
|
BorderColor
BorderWidth
|
&H008080FF&
3
|
Line14
|
BorderColor
BorderWidth
|
&H008080FF&
3
|
CommandButton1
|
Name
Caption
BackColor
|
cmd_exit
E&xit
&H00FFC0FF&
|
Form1
|
Name
Caption
BackColor
|
frm_latin2romawi
Roman Numeral Converter
&H0080FF80&
|
·
Klik menu View
=> Code, lalu kode program di
bawah ini :
Function Latin2Romawi(ByVal n As Currency) As String
Dim Satuan, Puluhan, Ratusan, Ribuan As Variant
Dim R1, R2, R3 As Integer
Satuan = Array("", "I", "II",
"III", "IV", "V", "VI",
"VII", "VIII", "IX")
Puluhan = Array("", "X", "XX",
"XXX", "XL", "L", "LX",
"LXX", "LXXX", "XC")
Ratusan = Array("", "C", "CC",
"CCC", "CD", "D", "DC",
"DCC", "DCCC", "CM")
Ribuan = Array("", "M", "MM",
"MMM")
Select Case n
Case 0 To 9
Latin2Romawi =
Satuan(Fix(n))
Case 10 To 99
R1 = Fix(n / 10)
Latin2Romawi =
Puluhan(Fix(R1)) + Latin2Romawi(n Mod 10)
Case 100 To 999
R2 = Fix(n / 100)
Latin2Romawi =
Ratusan(Fix(R2)) + Latin2Romawi(n Mod 100)
Case 1000 To 9999
R3 = Fix(n / 1000)
Latin2Romawi =
Ribuan(Fix(R3)) + Latin2Romawi(n Mod 1000)
End Select
End Function
Private Sub cmd_exit_Click()
End
End Sub
Private Sub Form_Activate()
Me.txt_angka.SetFocus
End Sub
Private Sub txt_angka_Change()
If Me.txt_angka.Text = "" Then
Me.lbl_terbilang.Caption =
""
ElseIf Me.txt_angka.Text <= 3999 Then
Me.lbl_terbilang.Caption =
Latin2Romawi(Me.txt_angka.Text)
ElseIf Me.txt_angka.Text > 3999 Then
Me.txt_angka.Text =
""
MsgBox "Angka tidak boleh
melebihi 3.999", vbOKOnly + vbInformation, "Angka Salah"
Me.lbl_terbilang.Caption =
""
Me.txt_angka.SetFocus
End If
End Sub
·
Jalankan Program dengan cara menekan tombol F5
pada keyboard atau pilih menu Run =>
Start
·
Hasilnya ketika program dijalankan :
* Ketika
angka yang diketik lebih kecil atau sama dengan ( <= ) 3999, maka angka akan
dkonversi ke dalam angka romawi seperti gambar di bawah ini :
Gbr 2
Gbr 3
* Ketika
angka yang diketik lebih besar ( > ) dari 3999, maka akan muncul pesan
seperti gambar di bawah ini :
Gbr 4
Download
Program Roman Numeral Converter disini
Tidak ada komentar:
Posting Komentar
Pos kan komentar anda !