Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default On Time code

Is there anyway of using the OnTime command which when reached will exit the
program unless a specific number is inserted into a input box.

Can you advise f the code?

Many thanks.

Kevin.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default On Time code

Don't know where OnTime comes into it, but the test can be

ans = Inputbox("Inut number")
If ans < 23 Then End

--

HTH

RP
(remove nothere from the email address if mailing direct)


"kevin" wrote in message
...
Is there anyway of using the OnTime command which when reached will exit

the
program unless a specific number is inserted into a input box.

Can you advise f the code?

Many thanks.

Kevin.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default On Time code

Kevin,

If you are using a standard input box I don't think so. You can create a
custom form and show it as a modeless form in XL2000 or higher, then have an
OnTime command check whether the value has been entered by a certain time.
OnTime is not that reliable however and this could easily mess up. So, I've
illustrated a better technique using a timer control:

'Put this in a general Module
'first technique using OnTime, which is easily messed up
'by clicking in the formula bar
'create a userform called frmPassword and add a text box called txtInput

Option Explicit
Option Private Module

Public dtTimeOut As Date 'used by second technique

Sub UnReliableTestForPassword()
frmPassword.Show vbModeless
Application.OnTime Now + TimeSerial(0, 0, 20), "CheckPassword"
End Sub

Sub CheckPassword()
Dim strCheck As String
strCheck = frmPassword.txtInput.Text
Unload frmPassword
If strCheck < "abc" Then
MsgBox "You password was not entered correctly", vbOKOnly, "Timed Out"
End
Else
MsgBox "System access granted", vbOKOnly, "Validation confirmed"
'run other macro to launch system here
End If
End Sub

'second technique using my VBA Timer control which is less easily
circumvented
'add the timer control from
'http://www.enhanceddatasystems.com/ED/Pages/ExcelTimer.htm
'to frmPassword

Sub MoreReliableTestForPassword()
dtTimeOut = Now + TimeSerial(0, 0, 20)
frmPassword.Show vbModeless
With frmPassword.Timer1
.Interval = 1000
.Enabled = True
End With
End Sub

'and put this in frmPassword's code section
Private Sub Timer1_Timer()
Dim strCheck As String
If Now dtTimeOut Then
Timer1.Enabled = False
strCheck = frmPassword.txtInput.Text
If strCheck < "abc" Then
MsgBox "You password was not entered correctly", vbOKOnly, "Timed
Out"
End
Else
MsgBox "System access granted", vbOKOnly, "Validation confirmed"
'run other macro to launch system here
End If
Unload Me
End If
End Sub

Robin Hammond
www.enhanceddatasystems.com

"kevin" wrote in message
...
Is there anyway of using the OnTime command which when reached will exit
the
program unless a specific number is inserted into a input box.

Can you advise f the code?

Many thanks.

Kevin.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default On Time code

Robin,

Many thanks. This works. I was just wondering if there is something similar
for dates. e.g if you want it to time out after say 5 days?

Kind Regards

"kevin" wrote:

Is there anyway of using the OnTime command which when reached will exit the
program unless a specific number is inserted into a input box.

Can you advise f the code?

Many thanks.

Kevin.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default On Time code

Kevin,

Glad it works. I seriously doubt it would be reliable to try it for long
periods.

Robin Hammond
www.enhanceddatasystems.com

"kevin" wrote in message
...
Robin,

Many thanks. This works. I was just wondering if there is something
similar
for dates. e.g if you want it to time out after say 5 days?

Kind Regards

"kevin" wrote:

Is there anyway of using the OnTime command which when reached will exit
the
program unless a specific number is inserted into a input box.

Can you advise f the code?

Many thanks.

Kevin.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time with VBA code Dale G[_2_] Excel Discussion (Misc queries) 8 September 23rd 09 11:22 PM
Time code albertmb Excel Discussion (Misc queries) 0 February 23rd 09 11:59 AM
Time Code Greg Brow Excel Programming 2 February 11th 05 12:19 PM
Run-time error from my code Matt Excel Programming 5 June 24th 04 03:32 AM
Same VBA code, different run time Bill Li Excel Programming 1 October 14th 03 06:04 AM


All times are GMT +1. The time now is 04:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"