Media (2)

Trik ini akan membuat sebuah fungsi baru pada OpenOffice yang membuat angka menjadi teks. misalnya 1.550 menjadi “seribu lima ratus lima puluh”. dengan menggunakan fungsi terbilang.

1. pilih menu Tools | Macros | organize Macros | OpenOffice.org Basic

screenshot-untitled-1-openofficeorg-calc

2. buat sebuah modul baru dan beri nama convert (ini hanya contoh, modul bisa diberi nama apa saja) screenshot-openofficeorg-basic-macros1

screenshot-new-module

3. hapus isi dari modul baru yang kita buat

screenshot-my-macros-dialogsstandard-openofficeorg-basic

4. copy dan paste kode berikut

Function TeksKeAngka(ByVal n As Double) As String
Dim sSatuan()
Dim s As String
sSatuan() = Array("nol", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas", "dua belas", "tiga belas", "empat belas", "lima belas", "enam belas", "tujuh belas", "delapan belas", "sembilan belas", "dua puluh")
s = ""
If n > 999 and n < 2000 Then
s = "seribu"
n = n MOD 1000
If n = 0 Then
TeksKeAngka = s
Exit Function
End If
s = s & " "
End If
If n > 199 Then
s = s & sSatuan(Fix(n / 100)) & " ratus"
n = n MOD 100
If n = 0 Then
TeksKeAngka = s
Exit Function
End If
s = s & " "
End If
If n > 99 and n < 200 Then
s = "seratus"
n = n MOD 100
If n = 0 Then
TeksKeAngka = s
Exit Function
End If
s = s & " "
End If
If n > 20 and n < 100 Then
s = s & sSatuan(Fix(n / 10)) & " puluh"
n = n MOD 10
If n = 0 Then
TeksKeAngka = s
Exit Function
End If
s = s & " "
End If
TeksKeAngka = s & sSatuan(n)
End Function

Function Terbilang(ByVal n) As String
Dim sBil()
sBil = Array( "", "ribu", "juta", "milyar", "triliun", "quadriliun")
Dim i As Integer
Dim iInt As Integer
Dim s As String
Dim dInt As Double
dInt = Fix(n)
If (dInt < 2000) Then
Terbilang = TeksKeAngka(CInt(dInt))
Exit Function
End If
i = 0
s = ""
Do While dInt > 0
iInt = CInt(dInt - Fix(dInt / 1000) * 1000)
If iInt <> 0 Then
If Len(s) > 0 Then s = " " & s
s = TeksKeAngka(iInt) & " " & sBil(i) & s
End If
i = i + 1
dInt = Fix(dInt / 1000)
Loop
Terbilang = s
End Function

5. terakhir, save dan fungsi terbilang dapat digunakan.

screenshot-my-macros-dialogsstandard-openofficeorg-basic-2

contoh penggunaanya, beri nilai sebuah angka pada cell A1 misal 1550, dan pada A2 isi cell dengan fungsi =terbilang(A1).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s