skip to main
|
skip to sidebar
home
FORUM
File
Total Kategori
Kategori
*Application By ARBI Blog's
(9)
*Dasar Visual Basic
(2)
CommandButton
(2)
Context Menu
(2)
File
(2)
Folder
(2)
Form
(23)
Keyboard
(2)
Label
(4)
ListBox
(2)
ListView
(3)
Menu
(1)
Mouse
(2)
MS.EXCEL
(3)
Registry
(2)
String
(1)
Textbox
(10)
TreeView
(1)
Windows XP
(5)
Show All Kategory
Archive
►
2012
(1)
►
Januari
(1)
►
2011
(11)
►
November
(2)
►
September
(1)
►
Juni
(1)
►
Maret
(4)
►
Februari
(3)
►
2010
(5)
►
Oktober
(2)
►
September
(2)
►
Februari
(1)
▼
2009
(59)
►
Desember
(1)
►
November
(33)
►
Oktober
(14)
▼
September
(11)
Hanya Huruf yang bisa di Input dalam TextBoxt
Hanya Angka / Numerik yang bisa di Input dalam Tex...
Setting Aligment Label
Mengganti Caption Label
Membuat Form Ellip's
Animasi Form Keluar ( Bergerak Keatas `)
Form Hanya Jalan 1x
Mengatur Lebar (Width) Colom atau Tinggi (Height) ...
Mendapatkan Value Tinggi (Height) Pada Row (A1) MS...
Excel ( Menampilkan Value Pada Kolom A1 )
Excel ( Merger / Unmerger)
Recent Comments
Blogroll
Materi Kuliah Api
Contoh Aplikatif : Word and Excell Generator
16 tahun yang lalu
DevPage
VB Helper: Tips, Tricks, & Example Programs for Visual Basic Developers
VBTown - Visual Basic Tutorial
Member
Selasa, 29 September 2009
Hanya Angka / Numerik yang bisa di Input dalam TextBoxt
PERSIAPAN
PROPERTIES
NO
CONTROL
ITEM
NAME
VALUE
KETERANGAN
1.
TextBox
1
Text
""
kosongkan
Cara Pertama :
Masukkan souce ini ke dalam Form :
Private Sub Form_Load() Text1.Text = "" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If Not (KeyAscii >= Asc("0") & Chr(13) And KeyAscii <= Asc("9") & Chr(13)) Then Beep KeyAscii = 0 End If End Sub
Cara Kedua :
Masukkan souce ini ke dalam Form :
Private Sub Form_Load() Text1.Text = "" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 47 Or KeyAscii > 57 Then Beep KeyAscii = 0 End If End Sub
Cara Ketiga :
Masukkan souce ini ke dalam Form :
Private Sub Form_Load() Text1.Text = Empty End Sub ' USAGE 'Create a form a text box Private Sub Text1_KeyPress(KeyAscii As Integer) ' Precision is 2 in this case ' Send the Precision Value same in both the Functions Call ValidateNum(Text1, 2, KeyAscii) End Sub Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) Call ValidateDel(Text1, 2, KeyCode) End Sub
Masukkan souce ini ke dalam Module :
Option Explicit ' For validating the Floating Point Numbers ' MODULE Public Sub ValidateDel(txtnum As TextBox, ByVal m_Precision As Integer, KeyCode As Integer) Dim m_NumBeforeDot As Integer, m_NumAfterDot As Integer Dim TempInt As Integer If KeyCode = vbKeyDelete Then If m_Precision > 0 Then TempInt = InStr(txtnum, ".") If TempInt > 0 Then m_NumBeforeDot = TempInt - 1 m_NumAfterDot = Len(txtnum) - TempInt Else m_NumBeforeDot = Len(Trim(txtnum)) m_NumAfterDot = 0 TempInt = txtnum.MaxLength - m_Precision End If If (txtnum.SelStart = TempInt - 1) Then If m_NumBeforeDot + m_NumAfterDot >= txtnum.MaxLength - m_Precision Then KeyCode = 0 End If End If End If End If End Sub Public Sub ValidateNum(txtnum As TextBox, ByVal m_Precision As Integer, KeyAscii As Integer) Dim m_NumBeforeDot As Integer, m_NumAfterDot As Integer Dim TempInt As Integer If (KeyAscii <> vbKeyReturn) And _ ((KeyAscii < vbKey0) Or (KeyAscii > vbKey9)) And _ (KeyAscii <> vbKeyBack) Then If KeyAscii = 46 Then ' Dot. If m_Precision = 0 Then KeyAscii = 0 Exit Sub Else If InStr(txtnum, ".") > 0 Then KeyAscii = 0 Exit Sub End If End If Else KeyAscii = 0 Exit Sub End If End If If KeyAscii = 0 Then Exit Sub If m_Precision > 0 Then TempInt = InStr(txtnum, ".") If TempInt > 0 Then m_NumBeforeDot = TempInt - 1 m_NumAfterDot = Len(txtnum) - TempInt Else m_NumBeforeDot = Len(txtnum) If txtnum.SelStart < m_NumBeforeDot - m_Precision Then KeyAscii = 0 Exit Sub End If m_NumAfterDot = 0 TempInt = txtnum.MaxLength - m_Precision End If If KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Then If Not (((m_NumBeforeDot < txtnum.MaxLength - m_Precision - 1) _ And (txtnum.SelStart < TempInt)) Or _ ((m_NumAfterDot < m_Precision) And (txtnum.SelStart >= TempInt))) Then KeyAscii = 0 End If ElseIf (KeyAscii = vbKeyBack) And (txtnum.SelStart = TempInt) Then If m_NumBeforeDot + m_NumAfterDot >= txtnum.MaxLength - m_Precision Then KeyAscii = 0 End If End If End If End Sub
0 komentar:
Posting Komentar
Posting Lebih Baru
Posting Lama
Beranda
Langganan:
Posting Komentar (Atom)
Logo
Sumbangan
Yahoo! Messager
Jimmy
Facebook
Jimmy
Pasang Link Banner :
Kumpulan Source VB
VISITOR
View shoutbox
About Me
Abe Kaz
rieb
---
| Registry Blog |
| FORUM |
------------------ Jangan lupa kasih Komentar yah ------------------
| Yahoo!Messager |
| Facebook |
---
0 komentar:
Posting Komentar