|
-
September 30th, 2009, 03:04 AM
#1
VB 2005 shortcut button
i need some help in understanding shortcut button code as well as writing them
i have created a button on a form that refuses to operate . the codes are right
its enabled, visible. mouse not disable.
but it just refuses to operate
so i'm trying out another way.. but programming a shortcut button
in the program left by my predecessor
Private Sub frmReport1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
Select Case e.KeyChar
Case ChrW(20) 'if staff press 'Ctrl-T' to terminate
Application.Exit()
End Select
End Sub
is ChrW(20) preset or something? i seriously cant figure it out
the operation of my shortcut button is that
when in form2, depressing the shortcut keys will call up form1 and close form2
-
September 30th, 2009, 01:29 PM
#2
Re: VB 2005 shortcut button
Here it is: The Paragraph sign!
although formatting loses it
that's the same as debug.print chrw(20)
-
September 30th, 2009, 01:55 PM
#3
Re: VB 2005 shortcut button
Is there any event handler code written for the button event handler? Just look out for buttonname_Clik(...) method in the form.
From the look of it, it looks like the code is written in the KeyPress event handler of the form.
To know what chrW(20) means, look at the ASCII table
http://www.asciitable.com/
ChrW() method returns the character associated with the decimal. For example ChrW(65) would return "A".
-
September 30th, 2009, 09:42 PM
#4
Re: VB 2005 shortcut button
hmmm... to SHUJA ALI there is no Ctrl + T in the ASCII site that u've shown me...
cant make out much.
perhaps u could show me how i should write my code let say i wanna press Ctrl + B to do the operation
By the way i've only been using VB'05 for 3weeks
-
September 30th, 2009, 10:36 PM
#5
Re: VB 2005 shortcut button
-
October 1st, 2009, 01:32 AM
#6
Re: VB 2005 shortcut button
XiaoToose, the VB.NET Forum is located here. This is the VB 6 Forum.
This seems like a global shortcut / a hook, am I correct ¿
Have look at MCLHotkey :
http://www.codeproject.com/KB/vbscript/mclhotkey.aspx
-
October 1st, 2009, 01:57 AM
#7
Re: VB 2005 shortcut button
hmmmm...
this is part of my code
i wanna add that by pressing Ctrl -Z (ChrW(26)) it will call another form and closes the current form
If e.KeyChar <> ChrW(13) And e.KeyChar <> "0" Then
KeyNum = e.KeyChar.ToString
Select Case KeyNum
Case ChrW(20) 'if staff press 'Ctrl-T' to terminate
End
Case "1" To "9" 'user response to the system according to the Landolt-C direction and system will record down the answer given by user
Case Else 'if user press other keys, there will have a beep sound, mouse being enabled and cursor will be shown until the user click on the ok button from error message
Beep()
mouse.EnableMouse()
Cursor.Show()
MessageBox.Show("Error", "Error", MessageBoxButtons.OK)
'Cursor.Hide()
'mouse.DisableMouse()
Timer1.Enabled = True
Exit Sub
End Select
End If
can anyone guide me?
do i just stuff the new line of case code in or wad?
-
October 2nd, 2009, 01:31 PM
#8
Re: VB 2005 shortcut button
[Moved to VB.NET]
The title of the thread is little confusing. it talks about button but then there doesn't seem to be any button there.
In order to trap Ctrl + Z keys, you would need to handle KeyDown event rather than KeyPress. A simple example would be
Code:
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Control And e.KeyCode = Keys.Z Then
MessageBox.Show("You pressed Ctrl + Z")
End If
End Sub
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|