Countdown with vba

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,280
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
With below code when its running userform1 label1 caption shows false values.
Is there any way to fix that?
Thanks in advance.


VBA Code:
Private Sub CommandButton1_Click()

a = UserForm2.TextBox1 = Value
b = UserForm2.TextBox2 = Value
c = UserForm2.TextBox3 = Value
d = UserForm2.TextBox4 = Value
e = UserForm2.TextBox5 = Value
f = UserForm2.TextBox6 = Value

n = a * 10 * 60 * 60 + b * 60 * 60 + c * 10 * 60 + d * 60 + e * 10 + f

Unload Me

UserForm1.Show

UserForm1.Label1.Caption = a & b & ":" & c & d & ":" & e & f
For i = 1 To n
Application.Wait (Now + #12:00:01 AM#)
DoEvents
UserForm1.Label1.Caption = Format(DateAdd("s", -1, UserForm.Label1.Caption), "hh:mm:ss")
UserForm1.Label3.Width = 858 - 858 * i / n

If UserForm1.Label1.Caption < #12:00:11 AM# Then
UserForm1.Label3.BackColor = vbRed
Beep

End If
Next i

End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi asyamonique. You need to replace the "=" with a "." It will probably work as a ".Value" but it should probably be a text value using a string variable (ie. Dim a as String). All other similar code will also require amendments. HTH. Dave
Code:
Dim as Double
a = UserForm2.TextBox1.Value
'OR
'a= Userform2.Textbox1.Text
'etc.

UserForm1.Label1.Caption = a + b & ":" & c + d & ":" & e + f
'OR....
'UserForm1.Label1.Caption = a & b & ":" & c & d & ":" & e & f
 
Upvote 0
Hello,
Thanks for your quick reply.
Unfortunately all ways hasn't worked.
It shows FALSE
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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