Results 1 to 13 of 13

Thread: VB.NET Change Any keypress by another on any where

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2021
    Posts
    166

    VB.NET Change Any keypress by another on any where

    I'm trying to make every time I press a key on the keyboard it is replaced by special symbols anscii:

    But in all textbox controls, richtexbox everything that can be entered a value.

    But I have a form2 called with: me.controls.add(form2)

    and also when I precionar selected in the second form that the same values ​​are valid for any.

    I thought of the following method:

    Create a module with all key definitions:

    Module:
    Code:
    Public sub keysubbcall()
    If e.keypress = Keys.A then
    Set selected.text = "AnciiCode112"
    end if
    
    If e.keypress = Keys.A then
    Set selected.text = "AnciiCode113"
    end if
    end sub
    So in the form's keydown call:

    Code:
    call module.kepress(keysubcall)
    But from what I thought it doesn't work well, I'd like it to work in all but only selected regardless of the form, even if it's an exe called done in vb being toplevel(false)

    is there any way to do this without using the method I've always done but always for something definite:

    Code:
    if e.keys = kepress.a then
    textbox1.text &= "Ancii112"
    end if
    But I would like it to work on any text input control.



    Code:
     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Form1.Keypreview = True
    End Sub
    
    ' Internet Ref:
    'REM : https://stackoverflow.com/questions/13727172/vb-net-keydown-event-on-whole-form
    '*************************************************************************
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyDown
        If  e.Control AndAlso e.KeyCode = Keys.S then
            ' Call your sub method here  .....
            YourSubToCall()
    
            ' then prevent the key to reach the current control
            e.Handled = False 
        End If
    End Sub
    Last edited by LiwisJames; Jul 13th, 2021 at 04:44 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width