Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2007, 10:07 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Product code generator

Need some formula to generate a 13 digit code for the products.

Yogesh
__________________
Yogesh
 
Old October 3rd, 2007, 10:50 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Should the code contain just numbers? Just Letters? A mixture? Are the first few letters and the last few numbers? Is the code completely random? Are duplicate codes acceptable?

There isn't very much information to go on to generate a solution for.

If you just want a random set of numbers extended to 13 digits, then this would work:
----------------------------------------------------
Dim iCnt As Integer, sCode As String
For iCnt = 1 to 13
  sCode = sCode & Int((Rnd * 10)) 'Concatenates random number between 0 and 9
Next
MsgBox "The generated code is: " & sCode
----------------------------------------------------

The above doesn't check to see if there was a duplicate. You'd have to check the result against a list for that.
If you are looking for anything more specific then more information on what is desired is needed.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Code generator and some other things Hyzac BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 13 October 9th, 2006 02:06 PM
The best code documentation generator for .VS 2005 woojtii C# 2005 1 July 3rd, 2006 01:17 PM
XSLT code generator for C# asap XSLT 0 April 14th, 2006 03:54 PM
Product Activation Code (Urgent) madhanagopal Pro VB.NET 2002/2003 5 September 6th, 2004 04:54 AM
XML Development Environment and code generator ptesone XML 0 December 22nd, 2003 10:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.