使用vb.net与ado一起使用 [英] work with ado using vb.net

查看:209
本文介绍了使用vb.net与ado一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个文本框,如果有人要键入字符串,我只想输入整数数据
数据类型,然后生成一条消息请输入integervalue",我正在使用vb.net并制作基于窗口的应用程序

i make a textbox i want to enter only integer data if any one want to type string
data type then generate a message "plese enter integervalue" i am using vb.net and making window based application

推荐答案

TextBox KeyPress Event中进行尝试.
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
               Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
            e.Handled = True
        End If
        If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
            e.Handled = False
        End If
    End Sub


这是非常基本的事情.您可以使用TextBox_KeyPress事件来执行此操作,您可以在其中添加此代码

This is very basic thing. You can do this using TextBox_KeyPress event, where you can add this code

If Not (e.KeyChar.IsDigit(e.KeyChar)) And _
e.KeyChar <> ChrW(Keys.Back) Then
e.Handles = True
End If


您可以尝试使用给定的代码,使用户只能输入数字.
You can try given code which enable to user to enter only Digit.
 Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        
If Not (Char.IsDigit(e.KeyChar)) Then e.Handled = True
   
 End Sub


这篇关于使用vb.net与ado一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆