冷凝重复操作

时间:2013-12-03 18:54:52

标签: javascript

我有一个重复的javascript函数,它重复的原因是它因为它在每个阶段设置变量a1,a2和a3。

我如何压缩它?

DB_connect()
SQL = "SELECT COUNT(*) FROM tbl_imts WHERE [REQUEST TYPE]='LETTER' AND [COLOR]='RED' AND [DATE RECEIVED] BETWEEN #"+SQLDate(date1)+"# AND #"+SQLDate(date1_2)+"#"
a1 = Number(cn.Execute(SQL).Fields(0).Value)
cn.Close()


DB_connect()
SQL = "SELECT COUNT(*) FROM tbl_imts WHERE [REQUEST TYPE]='LETTER' AND [COLOR]='GREEN' AND [DATE RECEIVED] BETWEEN #"+SQLDate(date1)+"# AND #"+SQLDate(date1_2)+"#"
a2 = Number(cn.Execute(SQL).Fields(0).Value)
cn.Close()


DB_connect()
SQL = "SELECT COUNT(*) FROM tbl_imts WHERE [REQUEST TYPE]='LETTER' AND [COLOR]='BLUE' AND [DATE RECEIVED] BETWEEN #"+SQLDate(date1)+"# AND #"+SQLDate(date1_2)+"#"
a3 = Number(cn.Execute(SQL).Fields(0).Value)
cn.Close()

0 个答案:

没有答案