Tutorial singkat ini menggunakan VB6.
Untuk mengubah text di textbox ke dalam format uang ternyata sangatlah mudah dilakukan. Hanya perlu beberapa baris kode di procedure KeyPress dan Change.
Ok, mari kita mulai.
1. buat form kosong di project vb.
2. tambahkan component textbox dan beri nama sebagai txtPrice
3. Masuk ke bagian kode, dan buat Procedure
txtPrice_KeyPress dan
txtPrice_Change seperti koding di bawah.
Private Sub txtPrice_Change()
If (Len(txtPrice.Text) > 0) Then
txtPrice.Text = FormatNumber(OriginalNum(txtPrice.Text), 0)
End If
txtPrice.SelStart = Len(txtPrice.Text)
End Sub
Private Sub txtPrice_KeyPress(KeyAscii As Integer)
If (txtPrice.Text = "" Or txtPrice.Text = "0") Then
txtPrice.Text = ""
End If
If (KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete) And Not (KeyAscii = 13) And Not (KeyAscii = 46) Then
Else
KeyAscii = 0
End If
If (Len(txtPrice.Text) > 0) Then
If (InStr(txtPrice.Text, ".") <> 0) Then
txtPrice.Text = Replace$(txtPrice.Text, ".", "")
End If
End If
End Sub
4. Tambahkan fungsi OriginalNum
Public Function OriginalNum(str) As String
'test dulu
test = "100"
testfmt = FormatNumber(test, 2)
temp = str
If InStr(testfmt, ",") > 0 Then 'format indonesia
OriginalNum = Replace(temp, ".", "")
ElseIf InStr(testfmt, ".") > 0 Then 'format english
OriginalNum = Replace(temp, ",", "")
End If
End Function
5. Kemudian test.
6. Finish.
Selamat Berkoding Ria....:D.
Category
- Android (42)
- Android Studio (1)
- Android Tips (5)
- Assembly (3)
- Bash (1)
- Basic (1)
- berita (16)
- Biology (5)
- Bisnis (1)
- C++ (2)
- Canvas (1)
- Christianity (3)
- Database (8)
- Donation (1)
- Ebook (8)
- Editor (1)
- Email (1)
- Free (2)
- gambar (3)
- Game (3)
- Gradle (1)
- Graphic (2)
- Gratis (1)
- handphone (1)
- hidupku (106)
- How To (41)
- Icon (2)
- informasi (49)
- Internet (2)
- Introduction to Programming Using Java (6)
- Java (9)
- Kaizen (1)
- Kata-kata bijak (43)
- Kata-kata Motivasi (46)
- Kesehatan (4)
- Library (1)
- LibreOffice (1)
- Linux (17)
- lua (2)
- Manga (1)
- mediawiki (1)
- Mitos (4)
- Motivasi (51)
- Motivation (12)
- musicXML (1)
- Musik (3)
- My Life (7)
- Myth (1)
- Networking (5)
- OOP (1)
- OpenDocument (1)
- Opini (84)
- Opinion (5)
- Otak (2)
- pemrograman (42)
- pemrograman visual (18)
- Pengembangan Diri (28)
- Pengenalan Pemrograman Menggunakan Java (7)
- Pengetahuan dasar (1)
- Personal Building (34)
- PHP (1)
- Printer (3)
- Programming (1)
- Qt (4)
- Quote (1)
- Review (2)
- Saran (2)
- Science (1)
- Script (1)
- Security (2)
- Sistem Informasi (11)
- Situs (4)
- Slackware (20)
- Social (2)
- Software (28)
- SQLite (1)
- Teknologi (2)
- thunderbird (1)
- Tips (1)
- Tumbuhan (2)
- Tutorial (15)
- Video (2)
- virus (2)
- Visual Basic 6 (5)
- Windows (8)
- Windows 10 (1)
- Windows 8 (2)
- Wise Agenda (41)
Diberdayakan oleh Blogger.
Rabu, 09 Mei 2012
Mengubah Text di Textbox ke dalam Format Uang secara Real Time
by Unknown | 
in Visual Basic 6
at Rabu, Mei 09, 2012
- Pencampuran semua warna menghasilkan warna apa?
- Konversi Pound (Lbs) ke Kg
- Setting DHCP Server pada ZTE F660 (ZXHN F660)
- 5 Mesin Pencari Buku
- benarkah Combantrin bisa menyembuhkan sakit gigi?
- Port Forwarding di ZTE f660
- Mengatasi The Panel key is locked Sony 3LCD Projector
- Arti Songong
- Membaca bersuara atau membaca diam?
- Biji Terkecil dan Biji Terbesar Di Dunia
alhamdulillah nemu juga script nya :D mkasi yaaa :) pokonya sukses terusssssss ^_^
BalasHapusSama-sama... Ada beberapa kekurangan dari code di atas, tapi saya gak ingat apa. Gak megang VB6 lagi sekarang, udah megang Qt. :)
Hapus