VB经验谈:限制输入的文本框
PublicClassMyTextBox
InheritsSystem.Windows.Forms.TextBox Privatem_strValidTextAsString="0123456789. -"&Chr(13).ToString Privatem_blnEditableAsBoolean=True #Region"Windows窗体设计器生成的代码" PublicSubNew() MyBase.New() '该调用是Windows窗体设计器所必需的。 InitializeComponent() '在InitializeComponent()调用之后添加任何初始化 EndSub 'UserControl1重写dispose以清理组件列表。 ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean) IfdisposingThen IfNot(componentsIsNothing)Then components.Dispose() EndIf EndIf MyBase.Dispose(disposing) EndSub 'Windows窗体设计器所必需的 PrivatecomponentsAsSystem.ComponentModel.IContainer '注意:以下 '可以使用Windows窗体设计器修改此过程。 '不要使用代码编辑器修改它。 PrivateSubInitializeComponent() components=NewSystem.ComponentModel.Container EndSub #EndRegion PrivateSubMyTextBox_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)HandlesMyBase.KeyPress DimstrLocalStringAsString IfEditAbleThen strLocalString=m_strValidText&Chr(8).ToString Else strLocalString=m_strValidText EndIf IfUCase(strLocalString).IndexOf(UCase(e.KeyChar))<0Then e.Handled=True Beep() Else EndIf EndSub PublicPropertyValidText()AsString Get Returnm_strValidText EndGet Set(ByValValueAsString) m_strValidText=Value EndSet EndProperty PublicPropertyEditAble()AsBoolean Get Returnm_blnEditable EndGet Set(ByValValueAsBoolean) m_blnEditable=Value EndSet EndProperty EndClass-> 上一篇:VB编程:WindwosAPI全攻略 下一篇:FileSystemObject读写文件 更多相关文章
|
推荐文章
精彩文章
|