YasserKhalil2019

T4314_Change Language In TextBox KeyDown Event KeyCode Table

Nov 13th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. https://excel-egy.com/forum/t4314
  2. ---------------------------------
  3.  
  4. 'KeyCode Table
  5. 'http://www.foreui.com/articles/Key_Code_Table.htm
  6. '-------------------------------------------------
  7.  
  8. 'In Standard Module
  9. '------------------
  10. #If Win64 Then
  11. Private Declare PtrSafe Function Keyboard Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal ss As String, ByVal sss As Long) As LongPtr
  12. #Else
  13. Private Declare Function Keyboard Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal ss As String, ByVal sss As Long) As Long
  14. #End If
  15.  
  16. Sub SetArabic()
  17. Call Keyboard("00000401", 1)
  18. End Sub
  19.  
  20. Sub SetEnglish()
  21. Call Keyboard("00000409", 1)
  22. End Sub
  23.  
  24. 'In UserForm Module
  25. '------------------
  26. Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  27. If KeyCode = 119 Then 'F8 = 119
  28. Call SetArabic
  29. ElseIf KeyCode = 116 Then 'F5 = 116
  30. Call SetEnglish
  31. End If
  32. End Sub
Add Comment
Please, Sign In to add comment