以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  下拉列表框的年份值自动更新  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=174275)

--  作者:lfz
--  发布时间:2022/1/8 17:56:00
--  下拉列表框的年份值自动更新

下拉列表框的年份值自动更新自动生成呢,每年加一次代码

Dim cbx As WinForm.ComboBox = e.Form.Controls("ComboBox1") \'所属期
Select Case vars("y")
    Case  "2018"
        cbx.ComboList = "2018年1月|2018年2月|2018年3月|2018年4月|2018年5月|2018年6月|2018年7月|2018年8月|2018年9月|2018年10月|2018年11月|2018年12月"
    Case "2019"
        cbx.ComboList = "2019年1月|2019年2月|2019年3月|2019年4月|2019年5月|2019年6月|2019年7月|2019年8月|2019年9月|2019年10月|2019年11月|2019年12月"
    Case "2020"
        cbx.ComboList = "2020年1月|2020年2月|2020年3月|2020年4月|2020年5月|2020年6月|2020年7月|2020年8月|2020年9月|2020年10月|2020年11月|2020年12月"
    Case "2021"
        cbx.ComboList = "2021年1月|2021年2月|2021年3月|2021年4月|2021年5月|2021年6月|2021年7月|2021年8月|2021年9月|2021年10月|2021年11月|2021年12月"
End Select


--  作者:有点蓝
--  发布时间:2022/1/9 19:59:00
--  
根据当前日期直接生成即可,没有必要使用变量

dim year as string = "|" & date.today.year & "年"
dim str as string
for i as integer = 1 to 12
str = str & year & i & "月"
next
msgbox(str)
Dim cbx As WinForm.ComboBox = e.Form.Controls("ComboBox1") \'所属期
cbx.ComboList = str.trim("|")


--  作者:lfz
--  发布时间:2022/1/10 11:03:00
--  回复:(有点蓝)根据当前日期直接生成即可,没有必要...
这段代码我也学习了,不过老师,我的这个变量是根据数据库的名称提取转换的,每年一个帐套数据库,比如:A公司2020.MDB,A公司2021.MDB  如果我还是想按照原来的思路怎样写代码呢
--  作者:有点蓝
--  发布时间:2022/1/10 11:10:00
--  
那就获取数据库名称作为年份呀

不然就只能每年改一次代码了