#1
|
|||
|
|||
10 Second Timer for Calling Bingo
Already have a spreadsheet ("Sheet1") that will display the bingo numbers at random when a button is clicked. There are two buttons ("Next Number" to display the next number and "New Game" to clear the board) that work just fine. I have tried to add a box that would "countdown from 10 seconds." Would like to create such a box that would (1)- cause no error when it get to "zero" and (2) would restart the "countdown" when the next number is displayed. How hard would it be to make this into an "automatic" program? Know there are commercial programs out there - but they have too many bells and info displayed. Any help would be appreciated!
Here are the two button marcos. Private Sub btnDraw_Click() Dim linenumber As Integer, numpick As Integer Dim bingonum As String linenumber = Range("E1").Value numpick = Range("B" & linenumber).Value Range("B" & linenumber).ClearContents If numpick > 60 Then bingonum = "O " & numpick ElseIf numpick > 45 Then bingonum = "G " & numpick ElseIf numpick > 30 Then bingonum = "N " & numpick ElseIf numpick > 15 Then bingonum = "I " & numpick Else bingonum = "B " & numpick End If Range("M8").Value = bingonum End Sub Private Sub btnReset_Click() Dim linenumber As Integer linenumber = 1 Do Range("B" & linenumber).Value = Range("A" & linenumber).Value linenumber = linenumber + 1 Loop Until Range("A" & linenumber).Value = "" Range("M8").ClearContents End Sub |
#2
|
|||
|
|||
.
Not certain how your code works. Can you post a copy of your workbook ? |
#3
|
||||
|
||||
Hi and welcome
in the future please select your code and press the #button while editing so as to wrap your code with tags. Thx
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#4
|
|||
|
|||
10 Second Timer for Calling Bingo Spreadsheet
Having never done this before, am trying to attach my spreadsheet as required.
If this doesn't come thru, pls provide instruction on how to "upload" a file. Thxs |
#5
|
|||
|
|||
.
Downloads at bottom ... Timer code : Code:
Option Explicit Sub BtnRaz_Click() mTimer3.TimerOff LblTemps.Caption = "00:00:10" With TButton1 .Caption = "Start" .ForeColor = &H8000& .Value = False End With End Sub Sub TimerStart() With TButton1 If .Value = True Then .Caption = "Stop" .ForeColor = &H80& mTimer3.TimerOn 1000 Else .Caption = "Start" .ForeColor = &H8000& mTimer3.TimerOff End If End With End Sub Private Sub TButton1_Click() TimerStart End Sub Private Sub UserForm_Initialize() Application.WindowState = xlMinimized With TButton1 .Caption = "Start" .ForeColor = &H8000& .Value = False End With Const C_VBA6_USERFORM_CLASSNAME = "ThunderDFrame" Dim ret As Long Dim formHWnd As Long 'Get window handle of the userform formHWnd = FindWindow(C_VBA6_USERFORM_CLASSNAME, Me.Caption) If formHWnd = 0 Then Debug.Print Err.LastDllError End If 'Set userform window to 'always on top' ret = SetWindowPos(formHWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) If ret = 0 Then Debug.Print Err.LastDllError End If End Sub Private Sub UserForm_Terminate() Application.WindowState = xlNormal mTimer3.TimerOff Unload Me End Sub |
#6
|
|||
|
|||
Thxs Logit.....For all your help/support, but I guess I didn't explain what I needed! When the spreadsheet is loaded there's the Bingo Calling board with a box that displays "00:10" second. When the "NEXT NUMBER" button is clicked on - a bingo number would appear and the countdown would begin. When the countdown get to zero - it stops. When the "NEXT NUMBER" is pressed again - another bingo number would appear and "00:10" would also appear and the countdown would begin again. Somehow, the countdown would be connected to the "NEXT NUMBER" button.
|
#7
|
|||
|
|||
Perhaps a simpler approach will suffice
@ Logit OP has 64bit Excel https://docs.microsoft.com/en-us/pre...31(v=office.14) https://www.jkp-ads.com/articles/apideclarations.asp |
#8
|
|||
|
|||
Hello NoSparks........thxs for you response and I see you added 1.6 kb to my original spreadsheet. However, I see nothing happening! What, where and/or how should something happen? I hoping for a "box" beneath the "Next Number" box that displays the "countdown timer."
|
#9
|
|||
|
|||
Why don't you post your workbook that has the box and code that causes an error when it gets to "zero"
instead of a workbook that doesn't contain the things you're requesting assistance with ? Then we would all be working on the same thing. Know what the box is, where the box is and can figure out why it errors when getting to zero. |
#10
|
|||
|
|||
Sorry NoSparks......guess I'm still not clear on "My Help Needed!" I didn't save any worksheet where I tried to create a "countdown timer!" None of them worked, some even locked up my computer. "LOGIT's" and "tutorials on YouTube and/or VBABooks" shows how to create "countdown timers" with using BUTTONS. What I'm hoping for - a marco/program that would add a "countdown timer box" beneath the "NEXT NUMBER" that would start each time the "NEXT NUMBER" is clicked. I've seen where an error will occur if the timer reach "Zero," that's why I wanted the "stop" prompt. If I'm out-of-line with this type request.....would someone please tell me. I'm 79 and not getting any younger and trying to create this board for a Senior Center here in Maryland. Thxs.
|
#11
|
|||
|
|||
.
This version should answer all your questions : Code:
Option Explicit Sub starttimer() On Error Resume Next Application.OnTime Now + TimeValue("00:00:01"), "nexttick" End Sub Sub nexttick() On Error Resume Next If Sheet1.Range("S9") = 0 Then Sheet1.Range("S9").Value = "0:0:10" Exit Sub End If Sheet1.Range("S9").Value = Sheet1.Range("S9").Value - TimeValue("00:00:01") starttimer End Sub Sub resettimer() Sheet1.Range("S9").Value = "0:0:10" End Sub Sub stoptimer() On Error Resume Next Application.OnTime Now + TimeValue("00:00:01"), "nexttick", , False End Sub |
#12
|
|||
|
|||
Logit & NoSparks..... LOGIT has hit in on the head for what I was looking for.......thank you, both!
|
#13
|
|||
|
|||
.
You are welcome. Glad we could help. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
#REF Error when calling VBA Function | RodneyJ | Excel Programming | 1 | 01-21-2016 12:42 PM |
Re-Calling Sent Email | freschij | Outlook | 1 | 12-06-2010 09:16 PM |
calling images with a button | sammer021486 | PowerPoint | 0 | 01-13-2010 08:24 AM |
first timer | papamadre | Forum Support | 1 | 10-24-2009 06:26 AM |
Bingo Cards | office_mike | Excel | 1 | 11-29-2008 10:17 PM |