在Excel中,我有一个使用IF()和OR()函数的函数。我希望在Access VBA中编写一个等价的函数。我该如何编写这方面的代码?
=IF(OR($X9=1,$X9=2,$X9=3),Y9-1,Y9)我打算使用这个if功能作为一个模块:
Function iyear(month as string, year as string) as string因此,在这种情况下,$X9将是月份,Y9将是一年。
发布于 2013-10-31 08:27:47
在VBA里,你可以做这样的事情
Function iyear(month As Long, year As Long) As Long
If month = 1 Or month = 2 Or month = 3 Then
iyear = year - 1
Else
iyear = year
End If
End Function
Sub Main()
MsgBox "month = 1, year = 2013" & vbNewLine & "iyear returns: " & iyear(1, 2013) & vbNewLine & vbNewLine & _
"month = 4, year = 2013" & vbNewLine & "iyear returns: " & iyear(4, 2013)
End Subhttps://stackoverflow.com/questions/19700597
复制相似问题