Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the operation method of VB.NET text box

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

VB.NET text box operation method is what, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

The operation mode of VB.NET text box is diversified, and it is relatively simple to apply. Developers can choose any method according to different needs to help them achieve the desired functions. Then the operation method of VB.NET text box introduced today is aimed at the restrictions on Chinese input, and so on.

Here is the code for the operation of the VB.NET text box:

'sunnyxing2004-04-01*** modification

Public Class MyTextBox

Inherits System.Windows.Forms.TextBox

Private m_strValidText As String = "0123456789."

& Chr (13). ToString

Private m_blnEditable As Boolean = True

# Region Code generated by the Windows forms designer

Public Sub New ()

MyBase.New ()

This call is required by the Windows forms designer.

InitializeComponent ()

'in InitializeComponent ()

Add any initialization after the call

End Sub

'UserControl1 overrides dispose to clean up the list of components.

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

Required for the Windows forms designer

Private components As System.ComponentModel.IContainer

'Note: the following procedures are required for the Windows forms designer

'you can modify this process using the Windows forms designer.

'don 't use the code editor to modify it.

Private Sub InitializeComponent ()

Components = New System.ComponentModel.Container

End Sub

# End Region

Private Sub MyTextBox_KeyPress (ByVal sender As Object

ByVal e As System.Windows.Forms.KeyPressEventArgs)

Handles MyBase.KeyPress

Dim strLocalString As String

If EditAble Then

StrLocalString = m_strValidText & Chr (8) .ToString

Else

StrLocalString = m_strValidText

End If

If UCase (strLocalString) .IndexOf (UCase (e.KeyChar)) < 0 Then

E.Handled = True

Beep ()

Else

End If

End Sub

Public Property ValidText () As String

Get

Return m_strValidText

End Get

Set (ByVal Value As String)

M_strValidText = Value

End Set

End Property

Public Property EditAble () As Boolean

Get

Return m_blnEditable

End Get

Set (ByVal Value As Boolean)

M_blnEditable = Value

End Set

End Property

Public Sub CheckText (ByVal sender As Object, ByVal e)

As System.EventArgs) Handles MyBase.TextChanged

Dim cha As Char

Try

Cha = CType (Me.Text.Substring (Me.SelectionStart-1,1), Char)

If m_strValidText.IndexOf (cha) < 0 Then

MeMe.Text = Me.Text.Remove (Me.SelectionStart-1,1)

End If

Catch ex As Exception

End Try

End Sub

End Class

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report