欢迎光临
我们一直在努力

VB.NET中让Textbox只能输入数字(二)-.NET教程,VB.Net语言

建站超值云服务器,限时71元/月

public class form1

inherits system.windows.forms.form

#region " windows 窗体设计器生成的代码 "

public sub new()

mybase.new()

该调用是 windows 窗体设计器所必需的。

initializecomponent()

在 initializecomponent() 调用之后添加任何初始化

end sub

窗体重写 dispose 以清理组件列表。

protected overloads overrides sub dispose(byval disposing as boolean)

if disposing then

if not (components is nothing) then

components.dispose()

end if

end if

mybase.dispose(disposing)

end sub

windows 窗体设计器所必需的

private components as system.componentmodel.icontainer

注意: 以下过程是 windows 窗体设计器所必需的

可以使用 windows 窗体设计器修改此过程。

不要使用代码编辑器修改它。

friend withevents textbox1 as system.windows.forms.textbox

<system.diagnostics.debuggerstepthrough()> private sub initializecomponent()

me.textbox1 = new system.windows.forms.textbox

me.suspendlayout()

textbox1

me.textbox1.location = new system.drawing.point(112, 96)

me.textbox1.name = "textbox1"

me.textbox1.tabindex = 0

me.textbox1.text = ""

form1

me.autoscalebasesize = new system.drawing.size(6, 14)

me.clientsize = new system.drawing.size(292, 266)

me.controls.add(me.textbox1)

me.name = "form1"

me.text = "form1"

me.resumelayout(false)

end sub

#end region

dim str as string = ""

private sub textbox1_textchanged(byval sender as system.object, byval e as system.eventargs) handles textbox1.textchanged

dim num as integer = 0

dim temp as string = ""

while num < textbox1.text.length

temp += "[0-9]"

num += 1

end while

if not (textbox1.text like temp) then

textbox1.text = str

textbox1.focus()

else

str = textbox1.text

end if

end sub

end class

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » VB.NET中让Textbox只能输入数字(二)-.NET教程,VB.Net语言
分享到: 更多 (0)