Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 1st, 2005, 04:32 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
Excape Function

I have an application that is running and doing a bunch of calculations while running through a loop a specific number of times. RIght now when I hit the "GO" button it runs and I am forced to wait till the calculations are complete.

What I want to do is set a variable at the beginning of the loop that checks for a specific value. If True then it exits the code. Can I change that variable to True based off of a Keyboard entry. Say the user hits "Esc" on the next pass through the loop it would set the variable to True thus exiting the code.

Is there a Keyboard Buffer?
How do I access this Buffer to test for a specific value?

THanks in Advance

Reply With Quote
  #2  
Old December 4th, 2005, 06:04 PM
LozWare's Avatar
LozWare LozWare is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2005
Posts: 531 LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level)LozWare User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 10 h 56 m 31 sec
Reputation Power: 46
Send a message via MSN to LozWare
Heres what you can do...

Make a textbox that is off the screen, but it must be enabled, and be visable. We will call it txtbox.

before a loop takes place, set focus to the textbox:
txtbox.SetFocus

In the Txtbox event 'keydown' do an IF statement that detects the ESC key is pressed, and enter the command END into the statement results...

Code:
Private Sub Txtbox_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 27 Then
    End
    End If
End Sub


So, what we have is a textbox that recieves focus while a calculation is taking place, and it will terminate the program when the ESC key (ascii 27) is pressed.

This is un-proffesional and i'm not even sure if it will work, but keyboard buffers involve all sorts of API which I cant be arsed to go into.

Reply With Quote
  #3  
Old December 5th, 2005, 03:52 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
This is a good idea and I can sort of get it to work. THe problem is that I have to have to cursor in the text box in order to get it to work.

While the code is running i hit the ESC key and nothing. Once the code stops I click in the text box and hit ESC and it works. THis is a bit confusing to me.

Note: I got rid of the End and just used a message box.

Private Sub txtbox_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 27 Then
MsgBox "You are attempting to stop the code"
End If

End Sub


Is there something I am doing incorrectly.
The txtbox is visable and enabled
I am setting the Focus before the loop, and tested it in the loop.

Thanks for yor help

Reply With Quote
  #4  
Old December 6th, 2005, 11:00 AM
blaze_r20 blaze_r20 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: md
Posts: 24 blaze_r20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 33 m 10 sec
Reputation Power: 0
Send a message via Yahoo to blaze_r20
I had a similiar situation on a different program i was working on, Instead, put the code that needs to loop on the timer_tick sub, (make sure it's no longer a loop) and then keep a counter so it knows when to exit, and make sure it has to check that a boolean is true before it executes the code. Simply have a button on your form then that will turn the appropriate boolean to false and stop the timer. I found that setting the timer to tick every 200 ms. allows the system to interject commands but whatever code you have attached to the timer still runs nicely.

Reply With Quote
  #5  
Old December 7th, 2005, 09:13 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 741 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 29 m 50 sec
Reputation Power: 22
I am quite new to the VB world. I think I understand what you wrote but am still a bit confused on the actual code.

1. Call timer_tick Sub from within the Loop
2. Once in the Timer_tick Sub start a timer, Set a boolean to True or false.

If I stop the timer then does the code stops in the loop?

How do you set the Boolean based on a Keyboard entry?

THANK FOR YOU HELP HERE....IT IS APPRECIATED

Reply With Quote
  #6  
Old December 12th, 2005, 04:21 PM
spuppett spuppett is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 78 spuppett User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 8 h 31 m 24 sec
Reputation Power: 4
Do you have a doEvents in the loop that does the calculating? If not, it may be the case that your txtbox doesn't get the message until the loop is done. Try that.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Excape Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT