I wrote this, with the help of B+, Steve, and others 4 1/2 years ago. Today I adjusted the size of the window to match on each side and slowed down the alarm beeps a little bit.
Edited: Also download the zip file which contains the LCD font needed for this and put it in the same folder.
Edited: Also download the zip file which contains the LCD font needed for this and put it in the same folder.
Code: (Select All)
'Vacuum Fluorescent Display Time/Date and Alarm by SierraKen on Dec. 4, 2020.
'This is my first clock using a font.
'Added: Alarm Clock.
'Added: Made AM/PM to stop moving.
'Added: "8" background LCD shadows.
'Added: Uses new MONOSPACE LCD font that aligns everything perfectly.
'Added: _TRIM$ to fix hours.
'Make sure PinballChallengeDeluxe-ae6g.ttf is in the same directory as this program.
'Font found here: https://www.fontspace.com/category/monospaced,lcd
'Thanks to B+, Steve, and the others on the QB64 forum for your help!
'June 4, 2025 Update: Fixed window size and slowed down alarm.
Dim f As Long
Dim background As Long
_Title "Time and Date - (S)et Alarm"
clock& = _NewImage(475, 200, 32)
Screen clock&
start:
fontfile$ = "PinballChallengeDeluxe-ae6g.ttf"
f& = _LoadFont(fontfile$, 62, "MONOSPACE")
_Font f&
Color _RGB32(32, 64, 32), _RGB32(0, 0, 0, 10)
_PrintString (10, 10), "88:88:88"
_PrintString (375, 10), "88"
_PrintString (20, 125), "88-88-8888"
background& = _CopyImage(0)
Do
_Limit 50
_PutImage , background&
a$ = InKey$
If a$ = " " Or a$ = "s" Or a$ = "S" Or a$ = "a" Or a$ = "A" Then GoSub alarm:
t$ = Time$
hour$ = Left$(t$, 2)
h = Val(hour$)
If h > 11 Then pmam$ = "PM": ampm4 = 2
If h < 12 Then pmam$ = "AM": ampm4 = 1
If h > 12 Then h = h - 12: hour$ = _Trim$(Str$(h))
If h = 0 Then hour$ = "12": pmam$ = "AM": ampm4 = 1
minute$ = Mid$(t$, 4, 2)
m = Val(minute$)
second$ = Right$(t$, 2)
s = Val(second$)
Color _RGB32(127, 255, 127), _RGB32(0, 0, 0, 10)
If h < 10 And h > 0 Then hour$ = "0" + hour$
_PrintString (10, 10), hour$ + ":" + minute$ + ":" + second$
_PrintString (375, 10), pmam$
_PrintString (20, 125), Date$
If alarm = 1 Then
month2$ = Left$(Date$, 2)
month2 = Val(month2$)
day2$ = Mid$(Date$, 4, 2)
day2 = Val(day2$)
year2$ = Right$(Date$, 4)
year2 = Val(year2$)
If year = year2 And month = month2 And day = day2 And h = hour2 And m = minute2 And s = second2 And ampm3 = ampm4 Then
Do
For snd = 400 To 500 Step 25
Sound snd, .5
Next snd
_Delay .5
_Title "** Alarm ** Press Any Key To Stop"
Loop Until InKey$ <> ""
alarm = 0
_Title "Time and Date - (S)et Alarm"
GoTo noalarm:
End If
End If
noalarm:
_Display
Cls
Loop Until a$ = Chr$(27)
_Font 16
End
alarm:
_Title "Set Alarm Here"
_Font 16
Cls
year:
_FreeImage background&
Input "Year (example: 2020): ", year
If year < 2020 Or year <> Int(year) Then GoTo year:
month:
Input "Month (1-12):", month
If month < 1 Or month > 12 Or month <> Int(month) Then GoTo month:
day:
Input "Day (1-31): ", day
If day < 1 Or day > 31 Or day <> Int(day) Then GoTo day:
hour:
Input "Hour (1-12): ", hour2
If hour2 < 1 Or hour2 > 12 Or hour2 <> Int(hour2) Then GoTo hour:
timeofday:
Input "AM or PM: ", ampm2$
If Left$(ampm2$, 1) = "a" Or Left$(ampm2$, 1) = "A" Then ampm3 = 1: GoTo minute:
If Left$(ampm2$, 1) = "p" Or Left$(ampm2$, 1) = "P" Then ampm3 = 2: GoTo minute:
GoTo timeofday:
minute:
Input "Minute (0-59): ", minute2
If minute2 < 0 Or minute2 > 59 Or minute2 <> Int(minute2) Then GoTo minute:
second:
Input "Second (0-59): ", second2
If second2 < 0 Or second2 > 59 Or second2 <> Int(second2) Then GoTo second:
alarm = 1
Cls
_Title "Time and Date - Alarm Set"
GoTo start:


