LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Catch a wrong value

I am looking for something that will catch if the user does not enter a
valid time. For example if they were to enter 0995 instead of 0955.

What I need is if they do enter a wrong value that a msgbox would pop up
telling them there value was not correct and then reselect the textbox so
that the value can be changed.


Below is my code as it stands now.

Private Sub TextBox11_AfterUpdate()

TextBox11.Value = Format(Application.Text(Replace(TextBox11.Value, ":",
""), "00\:00"), "hh:mm")

If TextBox12.Value "" Then
If TextBox11.Value "" Then

TextBox13.Value = (TimeValue(TextBox12.Value) -
TimeValue(TextBox11.Value)) * 24
TextBox13.Value = Format(TextBox13.Value, "0.0000")

TextBox1.Value = CDbl("0" & TextBox13.Value) + CDbl("0" &
TextBox23.Value) + CDbl("0" & TextBox33.Value) + CDbl("0" & TextBox43.Value)
+ CDbl("0" & TextBox53.Value) + CDbl("0" & TextBox63.Value) + CDbl("0" &
TextBox14.Value) + CDbl("0" & TextBox24.Value) + CDbl("0" & TextBox34.Value)
+ CDbl("0" & TextBox44.Value) + CDbl("0" & TextBox54.Value) + CDbl("0" &
TextBox64.Value)
TextBox1.Text = Format(TextBox1.Text, "0.0000")

End If
End If


'Test that to see if hours worked exceeds shift length

If TextBox12.Value "" Then
If TextBox11.Value "" Then

TextBox2 = TextBox4 - TextBox1

End If

If TextBox2.Value < 0 Then
TextBox2.Value = 0
GoTo Finished
End If

TextBox2 = TextBox4 - TextBox1
TextBox2.Text = Format(TextBox2.Text, "0.0000")

End If

Finished:

If TextBox12.Value = "" Then
TextBox13.Value = ""
End If

If TextBox11.Value = "" Then
TextBox13.Value = ""
End If

End Sub

 
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
CATCH-22 won't let me save the file Patrick Riley Excel Programming 19 October 12th 09 10:04 PM
Catch name of range Steven Excel Programming 4 May 20th 08 08:56 AM
Catch error Karen53 Excel Programming 4 April 12th 08 02:14 AM
catch event Nader Tewelde Excel Programming 2 June 22nd 07 07:59 PM
Catch-22 with Error 59 Dan[_28_] Excel Programming 0 November 13th 03 05:11 AM


All times are GMT +1. The time now is 10:33 AM.

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

About Us

"It's about Microsoft Excel"