Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 20th, 2006, 06:54 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default Unload the Form

Hi all !

I want to unload the form by pressing "ESC" Key but I hvae 48 Textfield in my Form so i will have to write use this function which is given below for each TextField. Pls anyone can give me any small method to do that

I mean can I get the exact object name(Like TextBox1) having Focus....

And I don't want to take array of TextBox.

Private Sub txtname_KeyPress(KeyAscii As Integer)
    If KeyAscii = 27 Then
        Unload Me
    End If
End sub


Thanks....

DPK..
__________________
DPK..
 
Old March 20th, 2006, 07:40 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi.
Set Form.KeyPreview = True.
This indicating whether the form will receive key events before the event is passed to the control that has focus.

Peko

 
Old March 21st, 2006, 12:05 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Hi Peko !
I used this so.. but it returning Compile Error: Invalid use of property and this word is being Highlighted..

Private Sub Form_Load()
    Set Form1.KeyPreview = True
End Sub

what can be problem..

thanks....


DPK..
 
Old March 21st, 2006, 04:44 AM
Authorized User
 
Join Date: Mar 2006
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Set it when you are in Design mode, not in run time.
Not type Set Form.KeyPreview = true in code, but set this property to true on form property panel.

Peko

 
Old March 21st, 2006, 06:50 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Hi peko !

  I don't know what was the problem before but it is working properly in Run Time also.
  So I did it.
  thanks for your consecutively replies...

  Thanks alot....

DPK..





Similar Threads
Thread Thread Starter Forum Replies Last Post
unload crystalActivexreportviewer sen22 VB Components 0 April 27th, 2007 02:01 AM
How to laod a form and unload current form? [email protected] Pro VB.NET 2002/2003 0 August 11th, 2006 09:15 AM
Delay form unload coolcatjk Pro VB.NET 2002/2003 1 December 15th, 2005 09:58 AM
Interrupting DoCmd.Close & Form Unload Event SerranoG Access 2 November 19th, 2005 03:41 PM
unload form in vb.net Kbera VB.NET 2002/2003 Basics 0 September 13th, 2004 07:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.