我有一个非常长的脚本修复,但我想知道我是否可以缩短它。
if year = 1894 Or year = 1895 Or year = 1896 Or year = 1897 Or year = 1898 Or year = 1899 Then fn1894()
If year = 1900 Or year = 1901 Or year = 1902 Or year = 1903 Or year = 1904 Or year = 1905 Or year = 1906 Or year = 1907 Or year = 1908 Or year = 1909 Then fn1900()
答案 0 :(得分:3)
由于这些年份相邻,试试这个:
If year >= 1894 And year <= 1899 Then fn1894()
If year >= 1900 And year <= 1909 Then fn1900()
答案 1 :(得分:2)
尝试
If year >= 1894 AndAlso year <= 1899 Then fn1984()
之后的脚本相同。顺便说一下,你应该考虑好的方法名称。
答案 2 :(得分:0)
Select Case True
Case iYear >= 1894 AndAlso iYear <= 1899
'fn1894()
Case iYear >= 1900 AndAlso iYear <= 1909
'fn1900()
Case Else
' else
End Select