We've noticed that you've been inactive for over 10 minute(s). We've stopped running the Shoutbox due to your inactivity. If you are back again, please click the I'm Back button below.
(12 June 2013 - 12:06 PM)As Well As Making It More Secure.
Replying to Keyboard Buttons
Topic Summary
Posted 25 October 2007 - 06:47 AM
Name:Basel Olayyan
Email:basel_baselll@hotmail.com
Opinion/*: Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.F1
MessageBox.Show("F1")
Case Keys.F5
MessageBox.Show("F5")
Case Keys.F6 AndAlso e.Shift
'Shift + F6
End Select
End Sub
I have used this code but when I but ant button or text box or any thing on the form this even not working and I don't know wht to do Plz if you have any Suggestion how to do it it well be appreciated
and thx for your help
Thanks for your help! changing the key preview property seems to have fixed the problem. Also, thanks for the code fixes, they all made sense and i have changed my code too.
Glad it helps. Keep up
EDIT: Try to read some books on this, it help understand more bout the basic of it, that way you can program more efficiently
Thanks for your help! changing the key preview property seems to have fixed the problem. Also, thanks for the code fixes, they all made sense and i have changed my code too.
Ok, i've tested. Just this code you posted earlier works fine for me
frmChild.MdiParent = me
frmChild.show
Sorry for giving you the wrong info on Controls.Add(). I seldom use MDI for my software. I find it confusing. Anyway, you also need to enable "KeyPreview" (Misc) for your main form for the keyboard event to work properly.
After seeing you code, i do have a few comment for you
Dim response As Microsoft.VisualBasic.MsgBoxResult
Use this instead of interger, that way your code of
If response = 6 Then
can be written as
If response = MsgBoxResult.Yes Then
which is a lot of easier to read and debug
The 2nd thing is try to use as much OOP strategy as possible. One of it is keep all this code that show your MDI Child in side one function, then call the function from those menu and key event. That way, it's easier to maintain the code. If you need to change the way your Help Windows appear, just change that function. All those event that call the function gets the changes. f not, you'll have to look through all your codes to make the changes, and you might miss it, trust me, it does, all the time
Instead of
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim response As Microsoft.VisualBasic.MsgBoxResult
Select Case e.KeyCode
Case Keys.F1
MsgBox("You asked for help")
Exit Sub
Case Keys.F2
frmWebHelp.MdiParent = Me
frmWebHelp.Show()
..... more code
Private Sub WebHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebHelpToolStripMenuItem.Click
frmWebHelp.MdiParent = Me
frmWebHelp.Show()
End Sub
You change it to
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim response As Microsoft.VisualBasic.MsgBoxResult
Select Case e.KeyCode
Case Keys.F1
MsgBox("You asked for help")
Exit Sub
Case Keys.F2
ShowfrmWebHelp()
..... more code
Private Sub WebHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebHelpToolStripMenuItem.Click
ShowfrmWebHelp()
End Sub
Private Sub ShowfrmWebHelp()
frmWebHelp.MdiParent = Me
frmWebHelp.Show()
End Sub
VB.Net implemented a lot of OOP features compare to VB6, it's totally re-engineered, thus why not use that to our fullest
hi, i was just checking in to see if you have worked out any solutions to my problem! thanks for your help!
Hi, sorry for the delay, quite busy with some customer supports lately. Btw, you code is done using visual basic 2005 right? I'm only using 2003. Installing 2005 now. If it goes successful tonight, i'll get back to you tomorrow
i have attached the code zipped. the frmChild that i have been referring to in the code is actually named frmWebHelp.
Sorry, do you mind to attach a more complete codes, cause i need to see what went wrong. The one you attached is just the button event. I can't see the property of those forms. If possible, you attach the .vb file of frmMain and frmChild