如何在VB.NET中自动生成id [英] How to autogenerate id in VB.NET

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

问题描述

我想要我的身份证如SR18 / 1然后是SR18 / 2 ....就像这样。我的代码将是增量...



我尝试了什么:



我无法生成SR18 / 2

解决方案

< blockquote>这取决于您想要做什么,以及如何存储信息。仔细思考这个问题很重要:弄错它会导致一些可怕的后果。



例如,您的第一个问题很简单:您是如何使用它的?这是一个单用户应用程序还是多用户?这产生了巨大的差异:多用户唯一ID需要比单个用户更多的关注!

数据存储系统也将影响您生成它的方式:如果您使用数据库,那么您可能会让它为你做大部分繁重的工作,因为他们通常有创建独特价值的系统,然后你可以用它作为你特定身份证格式的基础。



您需要考虑的其他问题:SR18位来自哪里?什么时候改变了?它是如何变化的? 18是今年的最后两位数吗?如果是这样,那么什么时候改变? 1月1日,或财政年度结束时(英国4月1日为税务目的,但如果公司财政年度取决于公司何时开始交易,可以是任何日期)? SR位何时发生变化,为什么?该怎么办?



它不像这行代码那么简单,甚至不是这个方法或这个算法 - 需要非数字自动ID值在你开始使用代码之前要仔细研究出来!


I want my id like SR18/1 and then SR18/2....like this.what will be my code for increment..

What I have tried:

I cant be able to generate SR18/2

解决方案

It depends on exactly what you want to do, and how you are storing the information. And it's important to think carefully about this: get it wrong and it can cause some horrible effects.

For example, your first problem is simple: how are you using this - is this a single user app, or multiuser? This makes a huge difference: multiuser unique IDs need a heck of a lot more care than single user!
The data storage system will also affect how you generate it: if you are using a database, then you can probably let it do most of the "heavy work" for you as they generally have systems for creating unique values which you can then use as a basis for your specific ID format.

Other problems you need to think about: where does the "SR18" bit come from? When does that change? How does it change? Is the "18" the last two digits of the year? If so, when does that change? January 1st, or at the end of the financial year (April 1st in the UK for tax purposes, but can be any date if it's a companies financial year depending on when the company started trading)? When does the "SR" bit change, and why? What to?

It's not as simple as "this line of code", or even "this method" or "this algorithm" - non-numeric automatic ID values need to be carefully worked out long before you start with code!


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

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