Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?
@  velma : (12 June 2013 - 01:27 PM) T_T We Should Deal Punishments To Procrastinators... Especially Me
@  Feelay : (12 June 2013 - 12:06 PM) As Well As Making It More Secure.

Replying to Keyboard Buttons


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


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


-Basel Olayyan

Jimmy89

Posted 04 January 2007 - 05:58 AM

thanks! i'll look into it!

faulty.lee

Posted 04 January 2007 - 12:37 AM

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

Jimmy89

Posted 03 January 2007 - 11:56 PM

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.

faulty.lee

Posted 03 January 2007 - 03:47 PM

Hi,

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

All the best

Regards
Faulty

faulty.lee

Posted 03 January 2007 - 02:41 PM

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

Regards & Happy New Year

Jimmy89

Posted 01 January 2007 - 10:16 AM

hi, i was just checking in to see if you have worked out any solutions to my problem! thanks for your help!

Jimmy89

Posted 27 December 2006 - 05:14 AM

yeah, sorry about that. I have just attached everything for those two forms

faulty.lee

Posted 27 December 2006 - 01:33 AM

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

Jimmy89

Posted 26 December 2006 - 11:44 PM

i have attached the code zipped. the frmChild that i have been referring to in the code is actually named frmWebHelp.

Review the complete topic (launches new window)