Jul 18, 2006 #1 OhioSteve MIS Mar 12, 2002 1,352 US In Access VBA, would the following code give me a random number between 1 and 1,000,000,000? Int(1000000000 * Rnd) + 1
In Access VBA, would the following code give me a random number between 1 and 1,000,000,000? Int(1000000000 * Rnd) + 1
Jul 18, 2006 #2 traingamer Programmer Jun 18, 2002 3,270 US It should. That's what the Help File examples says to do. Greg "Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill Upvote 0 Downvote
It should. That's what the Help File examples says to do. Greg "Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
Jul 18, 2006 Thread starter #3 OhioSteve MIS Mar 12, 2002 1,352 US This is my whole function. I think it returns a random ten digit string, with leading zeros. Tell me if it looks okay: Public Function getReportCode() Dim a As Long a = Int(1000000000 * Rnd) + 1 Dim b As String b = Right("0000000000" & a, 10) getReportCode = b End Function Upvote 0 Downvote
This is my whole function. I think it returns a random ten digit string, with leading zeros. Tell me if it looks okay: Public Function getReportCode() Dim a As Long a = Int(1000000000 * Rnd) + 1 Dim b As String b = Right("0000000000" & a, 10) getReportCode = b End Function
Jul 18, 2006 #4 PHV MIS Nov 8, 2002 53,708 FR You may raise overflow error as a Long (signed) can't be greater than 2147483647 Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886 Upvote 0 Downvote
You may raise overflow error as a Long (signed) can't be greater than 2147483647 Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
Jul 18, 2006 Thread starter #5 OhioSteve MIS Mar 12, 2002 1,352 US Is there a data type that lets you go to one billion? Upvote 0 Downvote
Jul 18, 2006 #6 MajP Technical User Aug 27, 2005 9,382 US You did it correctly and avoided the CINT function which would have caused problems http://www.xtremevbtalk.com/showthread.php?threadid=76270 Upvote 0 Downvote
You did it correctly and avoided the CINT function which would have caused problems http://www.xtremevbtalk.com/showthread.php?threadid=76270
Jul 18, 2006 #7 PHV MIS Nov 8, 2002 53,708 FR OOps, sorry, I had not properly counted the 0's :~/ Upvote 0 Downvote