1. Pengertian dan Fungsi
adl control yang dibuat sendiri oleh user dari control yang sudah ada, baik itu gabungan dari beberapa control atau tidak yang biasanya mempunyai fungsi tertentu
2. Code
Publiv Class txtKapital
inherits System.Windows.Forms.Textbox
Protected Overrides Sub OnKeyPress (Byval e As _ System.Windows.Forms.KeyPressEventArgs)
Select Case Asc(e.KeyChar)
Case 65 to 90 'dari A-Z
e.Handled = False
'dicetak d textbox
Case 32 ,8 'spasi dan backspace
e.handled = False
Case Else
e.Handled = True 'tidak dicetak d textbox
End Select
End Sub
Public Overrides Property Text () As String
Get
Return MyBase.Text
End Get
Set (Byval Value As String)
for i as integer = 1 to value.length
if Asc(Microsoft.VisualBasic.Mid(Value,i,1))>=65
and Asc(Microsoft.VisualBasic.Mid(Value,i,1))<=90 then
MyBase.text = Value
if i= value.length then
exit Property
End If
Else
MyBase.Text=""
Exit Property
End If
Next
if Value = Nothing then
MyBase.text=Value
Exit Property
EndIf
End Set
End Property
End Class
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment