在 Access 2010 中,我构建了一个日历。我现在正在整理它,想知道是否有一种“更清洁”的方式来编码一些东西。
我有几个功能:
Mousey()
--> 将光标更改为您的标准手指指针(不包含在标准 Access/VBA 库中)。
ClickDay(intClick As Integer)
--> 允许用户进入那天以获取更多详细信息
在我的日历上,我有 6 行,每行 7 天。每天调用Mousey()
函数_MouseMove
和ClickDay()
函数 on _Click()
。
我现在正在做的是为所有 42 个_Click()
调用我的ClickDay
函数的事件过程和另一个 42 个_MouseMove
调用我的函数的事件过程创建一个事件过程Mousey
。
显然,这是我想要精简的 84 个程序(每个程序 3 行)。
谁能想出一种方法将每个函数放在一个带有某种循环的过程中?这是我的功能:
Private Function ClickDay(intClick As Integer)
'Function that is called when one of the number boxes are clicked
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
'Get the pieces of the date based on box that is clicked
intYear = lblYear.Caption
intMonth = ChangeToMonth(lblMonth.Caption)
intDay = Me("t" & intClick).Value
'change global variable
gintDate = DateSerial(intYear, intMonth, intDay)
'go to the date clicked
DoCmd.OpenForm ("frmToday")
End Function
和
Public Function Mousey()
Dim hCur As Long
hCur = LoadCursor(0, IDC_HAND)
If (hCur > 0) Then
SetCursor hCur
End If
End Function