主题:  TO:“邦主”

udfans

职务:普通成员
等级:2
金币:0.0
发贴:417
注册:2002/2/2 12:32:55
#12002/8/17 21:38:32
请各位高手用VBS或JS帮我设计一个关于表单里自动生成文本框数据的小程序:或是采用别的什么办法!就是我在用表单提交数据时:其中有一个字段想用子程序生动生成并能提交至数据中,举例说:我现在想通过表单提交到数据库order_form中,其中数据库order_form有4个字段,ID、code、name、info;其中ID是数据库自动累加,不用提交,我现在想在code里生成诸如:20020815001一样的流水号,其中前8位是当前日期,后三位是当天流水号的序号(当然了,应该可以自动加1的),请各位高手帮忙设计一下,小生在这里先谢谢各位了



udfans

职务:普通成员
等级:2
金币:0.0
发贴:417
注册:2002/2/2 12:32:55
#22002/9/1 14:55:28
靠人不如靠已,经过自己的努力,终于完成了,把代码帖出来,别人也可以用,如果有不对的地方,高手可要指出啊!
sub subcode
dim startyear
dim startmon
dim startday
dim code
startyear = year(date)
startmon = month(date)
startday = day(date)
//code= <%=(rs_newcode.Fields.Item("form_id").value)%>
//code=Form1.goodsid.value
if startmon<10 then
startmon="0"&month(date)
end if
if startday<10 then
startday="0"&day(date)
end if
if startyear&startmon&startday<>left(<%=(rs_newcoder.Fields.Item("form_code").value)%>,8) then
code=001
else
code=int(mid(<%=(rs_newcoder.Fields.Item("form_code").value)%>,9,3))+1
end if
if len(int(mid(<%=(rs_newcoder.Fields.Item("form_code").value)%>,9,3))+1)=1 then
code="00"&cstr(code)
end if
if len(int(mid(<%=(rs_newcoder.Fields.Item("form_code").value)%>,9,3))+1)=2 then
code="0"&cstr(code)
end if
Form1.goods_code.value = startyear & startmon&startday&cstr(code)
end sub