Enable a key-skipping mechanism for a TextBox

Enable a key-skipping mechanism for a TextBox

' Enable the key-skipping mechanism for the input TextBox and for the input ' chars' Example: don't process the 'A', 'b' and '0' chars'   EnableTextBoxCharSkip(TextBox1, "A"c, "b"c, "0"c)Sub EnableTextBoxCharSkip(ByVal tb As TextBox, ByVal ParamArray keysToSkip() As _    Char)    ' save the array of keys textbox's Tag property    tb.Tag = keysToSkip    ' attach the txtbox's KeyPress event to the GenTextBox_KeyPress event     ' handler    AddHandler tb.KeyPress, AddressOf GenTextBox_KeyPressEnd Sub' Disable the key-skipping mechanism for the input textbox' Example: DisableTextBoxCharSkip(TextBox1)Sub DisableTextBoxCharSkip(ByVal tb As TextBox)    ' detach the textbox's KeyPress event from the GenTextBox_KeyPress event     ' handler    RemoveHandler tb.KeyPress, AddressOf GenTextBox_KeyPress    tb.Tag = NothingEnd Sub' Handle the textbox's KeyPress event to skip the keys of the array stored in ' the textbox's Tag propertyPrivate Sub GenTextBox_KeyPress(ByVal sender As Object, _    ByVal e As System.Windows.Forms.KeyPressEventArgs)    ' cast the generic Object sender to a TextBox    Dim tb As TextBox = DirectCast(sender, TextBox)    ' cast the textbox's Tag to an array of Char, that contains the chars to     ' skip    Dim keysToSkip() As Char = DirectCast(tb.Tag, Char())    ' if the pressed key is found in the array of "bad" keys,    '  overrides its default processing with "do nothing"    If Array.IndexOf(keysToSkip, e.KeyChar) > -1 Then e.Handled = TrueEnd Sub

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of