自动生成一串数字

来源:百度知道 编辑:UC知道 时间:2024/05/14 17:58:31
请教,在VB程序中点击Command1后如何自动生成一串数字(当前日期+0001,其中今天第一个生成的为:200609290001,第二个则生成为:200609290002,...),并显示在Text1.Text中!谢谢

例:
Dim c As Long'先声名一个全局变量

Private Sub Command1_Click()
Dim today As String
c = c + 1'累加
today = Format(Now, "yyyymmhh") & Format(c, "0000")'格式化
Text1 = today'显示
End Sub

Private Sub Form_Load()
c = 0'赋初值
End Sub