Trouble with a boolean statement using textbox value

RunTime91

Active Member
Joined
Aug 30, 2012
Messages
276
Office Version
  1. 365
Greetings ~

I am trying to create a Boolean condition with the value of a textbox which has its value expressed in "hh:mm:ss" format.

Below is the conditional statement which simply will not read correctly
Code:
If Format(.TextBox74.Text, "hh:mm:ss") > "3:00" Then
        .TextBox74.BackColor = vbGreen
      Else: .TextBox74.BackColor = vbRed
End If

The current value of TextBox 74 is 21:16 and yet it blows right past the 'then' and onto the 'Else'

Help??

Thank You ~
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I'm truly not sure but is it possible that after setting your textbox 74 to hh:mm:ss, VBA thinks you have 00:21:16 which is smaller then 3:00:00?

If this is the possibility, you can try to solve by changing hh:mm:ss by hh:mm
 
Upvote 0
Instead of this...

If Format(.TextBox74.Text, "hh:mm:ss") > "3:00" Then

try this...

If CDate(.TextBox74.Text) > #3:00# Then
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,495
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top