产生序列号 [英] Generate serial number

查看:160
本文介绍了产生序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一张表,其中包含有关汽车及其拥有者的信息以及其他一些文件,所有这些信息都将写在特殊列表上(一辆汽车及其拥有者一行),我需要在每一行中使用唯一的序列号桌子.两个字母和6个数字是此文档的标准. Valid是不同字段中字母和数字的单独生成器.代码应该这样,以便可以将其写入MS Access中的按钮,最好使用VBA:confused:

There is table with information about cars and its owners and some other documents, all this information will be writen on the special list (one row for one car and its owner), I need a unique serial number for each row in the table. Two letters and 6 numbers is a standart for this documents. Valid is a separate generator for letters and numbers, in diferent fields. Code should be such that it could be written to a button in MS Access, it is desirable VBA :confused:

推荐答案

好吧,我不能帮助我
但是,如果您希望使用c#中的某些代码可以帮助您,或者可能为您带来解决方案,那就是

well , i access i can''t help
but if you want some code in c# that can help you or may bring close the solution to you that is it :

private static string GenerateData(int lettersCount, int numsCount)
       {
           string str = string.Empty;
           Random ran = new Random();
           for (int i = 0; i < lettersCount; i++)
           {
               str += ((char)ran.Next(65, 91)).ToString();
           }
           for (int i = 0; i < numsCount; i++)
           {
               str += ran.Next(0, 9).ToString();
           }
           return str;
       }



我希望我能提供更多帮助.



i hope i can help more


如果您尝试使用随机生成器,迟早会得到一个副本.如果要使用随机序列,则每次都需要检查是否有重复.

我将使用增量系统,并将最后使用的系统保存在配置文件或Access表中.当您需要一个新号码时,只需增加最后一个号码,然后将其保存下来,以备下次使用. (基本上,这就是AUTO INCREMENT的工作方式,但它只使用数字,而不使用字母.)

目前尚不清楚字母或数字实际上是否需要含义,但这是您必须决定的事情.
If you try to use a random generator, sooner or later you will get a duplicate. If you want to use a random sequence, then you''ll need to check for dups each time.

I would use an incrementing system and save the last used in either a config file or Access table. When you need a new number, just increment the last one and save it back for next time. (That''s basically how the AUTO INCREMENT works, but it only uses numbers, not letters.)

It''s not clear whether the letters or numbers actually need to mean anything, but that''s something you''ll have to decide.


这篇关于产生序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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