如何生成自动发票号码...... [英] How to generate auto invoice number...

查看:177
本文介绍了如何生成自动发票号码......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这段代码但是这里有些问题,我不明白是什么问题

问题是:这是一个很好的空白数据库(意思是启动E000001)到E000009,之后就显示了数字E000011之后没有激怒数字。请帮助我。



我尝试过:



 Sub generate_inv()
Dim id_tmp As String
Query =通过InoviceNo desc从Invoice order中选择前1名InoviceNo
cmd =新OleDbCommand(query,cn)
dr = cmd.ExecuteReader
如果dr.HasRows = False那么
dr.Close()
id_tmp =E000001
否则
dr.Read()
id_tmp =格式(中(dr(InoviceNo),2,6)+ 1,E00000#)
结束如果
dr.Close()
txtInvoice.Text = id_tmp
End Sub

解决方案

问题是由您的格式字符串引起的,其中包含字符 E 这是一个格式控制字符。你需要用反斜杠来逃避它:

 id_tmp =格式(中(dr( < span class =code-string> InoviceNo), 2  6 )+  1   \ E00000#



或做类似的事情:

 num_tmp =格式(中(dr(  InoviceNo), 2  6 )+  1   00000#
id_tmp = E + num_tmp


I use this code but some problem here, I con't understand what is the problem
Problem is : It is fine work blank database(means starting E000001) to E000009, after that showing the number E000011 after that no incensed the number. Please Help me.

What I have tried:

Sub generate_inv()
Dim id_tmp As String
Query = "select top 1 InoviceNo from Invoice order by InoviceNo desc"
cmd = New OleDbCommand(query, cn)
dr = cmd.ExecuteReader
If dr.HasRows = False Then
dr.Close()
id_tmp = "E000001"
Else
dr.Read()
id_tmp = Format(Mid(dr("InoviceNo"), 2, 6) + 1,"E00000#")
End If
dr.Close()
txtInvoice.Text = id_tmp
End Sub

解决方案

The problem is caused by your format string, which includes the character E which is a formatting control character. You need to escape it with a backslash thus:

id_tmp = Format(Mid(dr("InoviceNo"), 2, 6) + 1,"\E00000#")


or do something like:

num_tmp = Format(Mid(dr("InoviceNo"), 2, 6) + 1,"00000#")
id_tmp = "E" + num_tmp


这篇关于如何生成自动发票号码......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆