ESC KEY PRESS

NEED HELP

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 30053 Views - Last Post: 01 October 2007 - 05:18 AM Rate Topic: -----

#1 rameshp  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 29-July 07

ESC KEY PRESS

Post icon  Posted 26 September 2007 - 12:18 AM

hi, every one. i am creating new project in this i have more than 40 controls..

i am press ESC key then application can be close. unload my form.


please give me a suggestions..


thanks
ram..
Is This A Good Question/Topic? 0
  • +

Replies To: ESC KEY PRESS

#2 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: ESC KEY PRESS

Posted 26 September 2007 - 01:59 AM

Set your command button's (the one you use to close your form) Cancel property to true.
Was This Post Helpful? 0
  • +
  • -

#3 rameshp  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 29-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 03:25 AM

View PostLouisda16th, on 26 Sep, 2007 - 01:59 AM, said:

Set your command button's (the one you use to close your form) Cancel property to true.



hi iRoBot,
in the calculator whenever u press ESC button it comes zero.

same like i am writing.my form close at any time ..
ok


thanks
ram...
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 04:22 AM

In VB6 you want to capture the KeyPress Event of the form, and check to see what key was pressed. For your situation, you'll need to determine if the Escape key was pressed, something like this

Private Sub Form_KeyPress(KeyAscii As Integer)
	If KeyAscii = vbKeyEscape Then
		End
	End If
End Sub



This will detect if the Esc button was pressed, if so it exits the application.

In VB.Net, its very similar

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)  Hndles Me.KeyDown 
	 If My.Computer.EscKeyDown Then
		   Exit
	 End IF
End Sub



Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#5 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: ESC KEY PRESS

Posted 26 September 2007 - 05:26 AM

I thought you wanted to close the form only. Sorry.....

View Postrameshp, on 26 Sep, 2007 - 03:55 PM, said:

hi iRoBot,

Btw. My name's not iROBOT ;)

This post has been edited by Louisda16th: 26 September 2007 - 05:27 AM

Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 05:30 AM

View PostLouisda16th, on 26 Sep, 2007 - 05:26 AM, said:

Btw. My name's not iROBOT ;)



Awww come on now Louisda16h, dont you want to be known as iRobot around the world? :P
Was This Post Helpful? 0
  • +
  • -

#7 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: ESC KEY PRESS

Posted 26 September 2007 - 05:36 AM

Robot: Programmed unit = Worker for Human <> Me ;).

I'd possibly prefer being called maker of iRobot :P. Robotics is what I want to do as a researcher if Im lucky enough to become one. :)
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 05:55 AM

View PostLouisda16th, on 26 Sep, 2007 - 05:36 AM, said:

Robot: Programmed unit = Worker for Human <> Me ;).

I'd possibly prefer being called maker of iRobot :P. Robotics is what I want to do as a researcher if Im lucky enough to become one. :)


But a programmers we work like robots, tirelessly putting in endless hours until the job is done. I'm stretching to make a connection here lol :P
Was This Post Helpful? 0
  • +
  • -

#9 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: ESC KEY PRESS

Posted 26 September 2007 - 06:58 AM

Quote

Awww come on now Louisda16h, dont you want to be known as iRobot around the world?

LMAO

Quote

Btw. My name's not iROBOT

That's exactly how I'd expect a Robot to respond.
Robot Designers try real hard to make Robots talk more like Humans ;)
Was This Post Helpful? 0
  • +
  • -

#10 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: ESC KEY PRESS

Posted 26 September 2007 - 07:13 AM

View Postborn2c0de, on 26 Sep, 2007 - 07:28 PM, said:

Robot Designers try real hard to make Robots talk more like Humans ;)

I'm not yet one.....not even close. Let me clear my B.E. degree first. :ph34r:
Was This Post Helpful? 0
  • +
  • -

#11 rameshp  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 29-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 08:23 PM

hi ever one

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
		  Unload Form1
	 End If
End Sub



use this code and set form properties as keypreview is true


then it solved..
my plan is to decrease the code and easy to under stand any one..


thanks for replaying all.
thanks
ram...

*ALWAYS use code blocks :)

This post has been edited by PsychoCoder: 26 September 2007 - 08:43 PM

Was This Post Helpful? 0
  • +
  • -

#12 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: ESC KEY PRESS

Posted 26 September 2007 - 08:37 PM

Actually, using KeyCode = vbKeyEscape like PsychoCoder did provides better readabiliy than KeyCode = 27.

This post has been edited by Louisda16th: 26 September 2007 - 08:38 PM

Was This Post Helpful? 0
  • +
  • -

#13 rameshp  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 29-July 07

Re: ESC KEY PRESS

Posted 26 September 2007 - 11:04 PM

View PostLouisda16th, on 26 Sep, 2007 - 08:37 PM, said:

Actually, using KeyCode = vbKeyEscape like PsychoCoder did provides better readabiliy than KeyCode = 27.



thanks for suggestion..


i have one problem..
in my form i use a calender control.
in this i am click once or enter key press then date display in label or text or mask edit control ..

i checked events at coding level display 5 only..

but i am right click on control and press help it gives property and events..

in that click event also available..

how to write a code give me a suggestions..
i am trying this code


Private Sub Calendar1_KeyPress(KeyAscii As Integer)
	If KeyAscii = vbLeftButton Then
		Label1.Caption = Calendar1
	ElseIf KeyAscii = vbKeyReturn Then
		Label1.Caption = Calendar1
	End If
End Sub


but it doesn't work..
give me correct solution..
bye..
immediately...
ram...
Was This Post Helpful? 0
  • +
  • -

#14 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: ESC KEY PRESS

Posted 27 September 2007 - 04:52 AM

I'm sorry but I'm not able to understand what you're trying to say.
Was This Post Helpful? 0
  • +
  • -

#15 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ESC KEY PRESS

Posted 27 September 2007 - 05:00 AM

View Postrameshp, on 26 Sep, 2007 - 11:04 PM, said:

but it doesn't work..
give me correct solution..
bye..
immediately...
ram...


Well, like others have said, I have no clue as to what you're asking for.

Second, saying to give you correct solution immediately isn't going to get you the type of attention you're looking for. We are all professionals and have lives, school, work, families, and we aren't here to be told by someone like you to immediately give you the solution to your problem
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2