-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.frm
145 lines (128 loc) · 3.95 KB
/
Form1.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Countdown to Disney"
ClientHeight = 5310
ClientLeft = 45
ClientTop = 330
ClientWidth = 7170
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "Form1.frx":0000
ScaleHeight = 5310
ScaleWidth = 7170
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton ExitButton
Caption = "Exit"
Height = 375
Left = 6000
TabIndex = 1
Top = 4800
Width = 975
End
Begin MSComCtl2.DTPicker DatePicker
Height = 375
Left = 120
TabIndex = 0
Top = 4800
Width = 1455
_ExtentX = 2566
_ExtentY = 661
_Version = 393216
Format = 24444929
CurrentDate = 44733
MaxDate = 73050
MinDate = 20285
End
Begin VB.Label CountdownLabel
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Countdown Text"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 2
Top = 360
Width = 4575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim vacationDate As Date
Dim dateDifference As Integer
Private Sub DatePicker_CloseUp()
vacationDate = DatePicker.Value
UpdateCaption
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub
Private Sub Form_DblClick()
ChgBackground
End Sub
Private Sub Form_Load()
Dim imgNum As Integer
ReadFile
UpdateCaption
ChgBackground
End Sub
Public Sub UpdateCaption()
dateDifference = DateDiff("d", Now, vacationDate)
If dateDifference < -1 Then
CountdownLabel.Caption = Abs(dateDifference) & " days since Disney"
ElseIf dateDifference = -1 Then
CountdownLabel.Caption = Abs(dateDifference) & " day since Disney"
ElseIf dateDifference = 1 Then
CountdownLabel.Caption = Abs(dateDifference) & " day until Disney!"
Else
CountdownLabel.Caption = dateDifference & " days until Disney!"
End If
End Sub
Public Sub WriteFile()
Dim intFile As Integer
Dim strFile As String
strFile = App.Path & "\save.dat"
intFile = FreeFile
Open strFile For Output As #intFile
Print #intFile, CLng(vacationDate)
Close #intFile
End Sub
Public Sub ReadFile()
Dim intFile As Integer
Dim strFile As String
Dim strFileContents As String
strFile = App.Path & "\save.dat"
intFile = FreeFile
Open strFile For Input As #intFile
Input #intFile, strFileContents
Close #intFile
If Not strFileContents < 20285 And Not strFileContents > 73050 Then
DatePicker.Value = CVDate(strFileContents)
vacationDate = DatePicker.Value
Else
DatePicker.Value = Now
vacationDate = DatePicker.Value
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
WriteFile
End Sub
Public Sub ChgBackground()
Randomize
imgNum = Int((22 - 1 + 1) * Rnd + 1)
Form1.Picture = LoadPicture(App.Path & "\img\" & imgNum & ".bmp")
End Sub