VB 字母+日期+数字 自动编号
VB字母+日期+数字自动编号如sn2008051601同一天的从sn2008051601sn2008051602……每生成一条记录后面的数字自动+1日期变了自动从01开始...
VB 字母+日期+数字 自动编号
如 sn2008051601
同一天的 从sn2008051601 sn2008051602 ……每生成一条记录 后面的数字自动+1
日期变了 自动从01开始
代码应该怎么写?要能运行的!
一个入库单编号 自动生成编号放text1.text就可以 但是这个现在我会了
sNo = "ST" & Format(Now(), "yymmdd") & "0001"
Text1.Text = sNo
怎么写日期变动后自动从0001开始,要怎么写! 展开
如 sn2008051601
同一天的 从sn2008051601 sn2008051602 ……每生成一条记录 后面的数字自动+1
日期变了 自动从01开始
代码应该怎么写?要能运行的!
一个入库单编号 自动生成编号放text1.text就可以 但是这个现在我会了
sNo = "ST" & Format(Now(), "yymmdd") & "0001"
Text1.Text = sNo
怎么写日期变动后自动从0001开始,要怎么写! 展开
展开全部
Public Function TreasuryNo(sNo As String) As String
TreasuryNo = Format$(Now, "yyyyMMdd")
If TreasuryNo <> Mid$(sNo, 3, 8) Then
TreasuryNo = "sn" & TreasuryNo & "01"
Else
TreasuryNo = "sn" & Right$(sNo, 10) + 1
End If
End Function
sNo 就是你每次生成的库存号码,这个号码要保存起来,或者要能获取到。这里没有做当天序号小于100的验证,因为你也没有提到如果单据多于99时序号怎么做,最好将序号改为4位。
TreasuryNo = Format$(Now, "yyyyMMdd")
If TreasuryNo <> Mid$(sNo, 3, 8) Then
TreasuryNo = "sn" & TreasuryNo & "01"
Else
TreasuryNo = "sn" & Right$(sNo, 10) + 1
End If
End Function
sNo 就是你每次生成的库存号码,这个号码要保存起来,或者要能获取到。这里没有做当天序号小于100的验证,因为你也没有提到如果单据多于99时序号怎么做,最好将序号改为4位。
展开全部
说明白点,记录用在哪里
先查询最大的后缀
select max(right(字段名,2)) from 表名 where mid(字段名,3,8)='20080516'
先查询最大的后缀
select max(right(字段名,2)) from 表名 where mid(字段名,3,8)='20080516'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim S As String, I As Long
For I = 1 To 99
S = "sn" & Format(Date, "YYYYMMDD") & Format(I, "00")
Print S
Next
End Sub
Dim S As String, I As Long
For I = 1 To 99
S = "sn" & Format(Date, "YYYYMMDD") & Format(I, "00")
Print S
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
记录存放于c:\1.txt文件中,每次重新运行,都从文件中读取最后一条记录,作为基准。
本程序假定每天操作不会超过99次,所以没有判断,如果超过99,后面就回出错。
Dim oldstr As String
Dim newstr As String
Dim s As String: Dim n As Long
Dim intY As Long: Dim intM As Long: Dim intD As Long
Dim intY1 As Long: Dim intM1 As Long: Dim intD1 As Long
Private Function GSHData(s As String, x As Long, y As Long, z As Long, n As Long)
x = Val(Mid(s, 3, 4)): y = Val(Mid(s, 7, 2)): z = Val(Mid(s, 9, 2)): n = Val(Mid(s, 11, 2))
End Function
Private Function GSHData1(s As String, x As Long, y As Long, z As Long)
x = Val(Left(s, 4)): y = Val(Mid(s, 5, 2)): z = Val(Right(s, 2))
End Function
Private Sub Command1_Click()
Call GSHData(oldstr, intY, intM, intD, n)
s = Format(Date, "YYYYMMDD")
Call GSHData1(s, intY1, intM1, intD1)
If intY = intY1 And intM = intM1 And intD = intD1 Then
n = n + 1
Else
n = 1
End If
newstr = "sn" & Format(Date, "YYYYMMDD") & Format(n, "00")
Open "c:\1.txt" For Append As #1
Print #1, newstr
Close
oldstr = newstr
Print newstr
End Sub
Private Sub Command2_Click()
Dim a As Date
a = Date
Print a
Print Format(a, "YYYY-MM-DD")
End Sub
Private Sub Form_Load()
Open "c:\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, oldstr
Loop
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open "c:\1.txt" For Append As #1
Print #1, newstr
Close
End Sub
本程序假定每天操作不会超过99次,所以没有判断,如果超过99,后面就回出错。
Dim oldstr As String
Dim newstr As String
Dim s As String: Dim n As Long
Dim intY As Long: Dim intM As Long: Dim intD As Long
Dim intY1 As Long: Dim intM1 As Long: Dim intD1 As Long
Private Function GSHData(s As String, x As Long, y As Long, z As Long, n As Long)
x = Val(Mid(s, 3, 4)): y = Val(Mid(s, 7, 2)): z = Val(Mid(s, 9, 2)): n = Val(Mid(s, 11, 2))
End Function
Private Function GSHData1(s As String, x As Long, y As Long, z As Long)
x = Val(Left(s, 4)): y = Val(Mid(s, 5, 2)): z = Val(Right(s, 2))
End Function
Private Sub Command1_Click()
Call GSHData(oldstr, intY, intM, intD, n)
s = Format(Date, "YYYYMMDD")
Call GSHData1(s, intY1, intM1, intD1)
If intY = intY1 And intM = intM1 And intD = intD1 Then
n = n + 1
Else
n = 1
End If
newstr = "sn" & Format(Date, "YYYYMMDD") & Format(n, "00")
Open "c:\1.txt" For Append As #1
Print #1, newstr
Close
oldstr = newstr
Print newstr
End Sub
Private Sub Command2_Click()
Dim a As Date
a = Date
Print a
Print Format(a, "YYYY-MM-DD")
End Sub
Private Sub Form_Load()
Open "c:\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, oldstr
Loop
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open "c:\1.txt" For Append As #1
Print #1, newstr
Close
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询