Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This code will put in a TAB CHARACTER into any TEX...
Author:
Solomon Closson
E-mail:
Click to e-mail author
Submitted:
11/16/2001
Version:
VB6
Compatibility:
VB6
Category:
String Manipulation
Views:
34837
This code will put in a TAB CHARACTER into any TEXT STRING such as a MenuItems Caption, a MsgBox, etc.. For Example if you've defined your own KeyDown Events in Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) you wouldn't want to use VB's Menu Editor Shortcuts option for every MenuItem (since you already have the shortcuts defined). So now all you have to do is let the user know what menuitem has what shortcut. But you want the Shortcuts to be displayed one tab character after the Title Caption of the MenuItem. To do this successfully we use: Chr$(vbKeyTab) The Chr$() function is a built in function that gets an integer value passed into the parameter. However to put in the Tab Characters integer (9), it would return the number 9 and not the Tab Character. So we pass vbKeyTab to this parameter and voila.
Declarations:
'none
Code:
'Example using a MenuItem and a MsgBox 'The MenuItem is Named mnuFileOpen 'The MenuItems Caption property will get put into the 'Form's Load Event Private Sub Form_Load() mnuFileOpen.Caption = "Open" & Chr$(vbKeyTab) & "Ctrl+O" End Sub 'Define the KeyCode and Shift Integers for mnuFileOpen Private Sub Form_KeyDown(KeyCode As Integer, _ Shift As Integer) Select Case Shift Case 2 'If the Ctrl Key is pressed If KeyCode = vbKeyO Then 'If the "o" Key is pressed Call mnuFileOpen_Click End If End Select End Sub 'Define the mnuFileOpen_Click() event Private Sub mnuFileOpen_Click() 'Actions to perform when the File/Open MenuItem 'is Clicked 'Example MsgBox "Here is a Message Box using the Tab Character" & vbCrLf & Chr$(vbKeyTab) & "What's up Doc!" End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement