真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net只能輸數(shù)字 vb文本框只能輸入數(shù)字

vb.net 讓相應(yīng)的textbox中只能輸入“中文字符、英文、數(shù)字”

每個(gè)textbox都有KeyPress事件(event),每次用戶輸入一個(gè)字符時(shí)檢測(cè),如不滿足則清空

我們提供的服務(wù)有:做網(wǎng)站、成都網(wǎng)站制作、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、古浪ssl等。為上千多家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的古浪網(wǎng)站制作公司

我現(xiàn)在不在vs下,你可以找到這個(gè)面板,綁定相應(yīng)的函數(shù)

比如只能顯示數(shù)字

Private?Sub?NumBox_KeyPress(KeyAscii?As?Integer)

If?Not?IsNumeric(NumBox.Text)?Then

NumBox.Text?=?""

End?If

End?Sub

只能顯示英語(yǔ)(a-z 97-122; A-Z 65-90;?8(退格)和13(換行))

Private?Sub?EngBox_KeyPress(KeyAscii?As?Integer)

If?Not?(KeyAscii?=?97?And?KeyAscii=122)?Or?(KeyAscii?=?90?And?KeyAscii=65)?Or?=?8?Then

EngBox.Text?=?""

End?If

End?Sub

只能顯示漢字(漢字的ASCII值要么小于0,要么是8(退格)和13(換行))

Private?Sub?ChineseBox_KeyPress(KeyAscii?As?Integer)

If?Not?KeyAscii??0?Or?KeyAscii?=?8?Or?KeyAscii?=?13?Then

ChineseBox.Text=""

End?If

End?Sub

做了一些小修改,不明白請(qǐng)及時(shí)追問(wèn),滿意敬請(qǐng)采納,O(∩_∩)O謝謝

如何在VB.NET 中限制文本框中只能輸入數(shù)字

以下是只能輸入數(shù)字和小數(shù)點(diǎn),并且小數(shù)點(diǎn)只能輸入一次

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Textbox1.KeyPress

If Char.IsDigit(e.KeyChar) or e.KeyChar = Chr(8) or e.KeyChar = "." Then

If e.KeyChar = "." And InStr(TextBox1.Text, ".") 0 Then

e.Handled = True

Else

e.Handled = False

End If

Else

e.Handled = True

End If

End Sub

VB.NET中讓Textbox只能輸入數(shù)字

Public Class Form ??? Inherits System Windows Forms Form

#Region Windows 窗體設(shè)計(jì)器生成的代碼

Public Sub New()??????? MyBase New()

該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的 ??????? InitializeComponent()

在 InitializeComponent() 調(diào)用之后添加任何初始化

End Sub

窗體重寫(xiě) dispose 以清理組件列表 ??? Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)??????? If disposing Then??????????? If Not (ponents Is Nothing) Then??????????????? ponents Dispose()??????????? End If??????? End If??????? MyBase Dispose(disposing)??? End Sub

Windows 窗體設(shè)計(jì)器所必需的??? Private ponents As System ComponentModel IContainer

注意: 以下過(guò)程是 Windows 窗體設(shè)計(jì)器所必需的??? 可以使用 Windows 窗體設(shè)計(jì)器修改此過(guò)程 ??? 不要使用代碼編輯器修改它 ??? Friend WithEvents TextBox As System Windows Forms TextBox??? Private Sub InitializeComponent()??????? Me TextBox = New System Windows Forms TextBox??????? Me SuspendLayout()??????? ??????? TextBox ??????? ??????? Me TextBox Location = New System Drawing Point( )??????? Me TextBox Name = TextBox ??????? Me TextBox TabIndex = ??????? Me TextBox Text = ??????? ??????? Form ??????? ??????? Me AutoScaleBaseSize = New System Drawing Size( )??????? Me ClientSize = New System Drawing Size( )??????? Me Controls Add(Me TextBox )??????? Me Name = Form ??????? Me Text = Form ??????? Me ResumeLayout(False)

End Sub

#End Region??? Dim str As String =

lishixinzhi/Article/program/net/201311/13841

VB.NET下,讓textbox只能輸入數(shù)字,小數(shù)點(diǎn),和負(fù)號(hào),我的代碼哪里有錯(cuò)?

private str as string 'str最好定義到外面

Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp

Dim d As Double

If Double.TryParse(TextBox1.Text, d) Or TextBox1.Text = "-" Or TextBox1.Text.Trim() = "" Then

str = TextBox1.Text

Else

TextBox1.Text = str

TextBox1.SelectionStart = TextBox1.Text.Length

TextBox1.Focus()

End If

End Sub

VB.NET中的DATAGRIDVIEW怎樣只能在表格中輸入數(shù)字呢

第一部、先定義一個(gè)單元格操作變量,如下

Dim cellEdit As DataGridViewTextBoxEditingControl = Nothing

第二部、然后在在控件的EditingControlShowing事件中添加入下代碼,參考如下:

Private Sub DataGridView3_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView3.EditingControlShowing

cellEdit = CType(e.Control, DataGridViewTextBoxEditingControl)

cellEdit.SelectAll()

AddHandler cellEdit.KeyPress, AddressOf dataGridView3_KeyPress

End Sub

第三部:在要控制的列加入控件鍵盤(pán)按鈕的代碼,如下面ROLL列是要控制的列

Private Sub dataGridView3_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles DataGridView3.KeyPress

Dim i As Integer = DataGridView3.CurrentCellAddress.X

Dim ColumnName As String = DataGridView3.Columns(i).Name

If (ColumnName = "rollno") Then

If Not Char.IsDigit(e.KeyChar) And e.KeyChar Chr(8) Then

e.Handled = True

End If

End If

End Sub


分享文章:vb.net只能輸數(shù)字 vb文本框只能輸入數(shù)字
轉(zhuǎn)載來(lái)源:http://weahome.cn/article/doogdih.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部