472,145 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

ASP Function not returning what I want

I am trying to build a page to generate some random data for a database that
I am working on... I thought this would be simple, but it has proven to be
more difficult... I am trying to create some functions to build a random
date. It keeps returning a string like, "9172006//" instead of "9/17/2006".
What's making this do that?

Function RandomNumber(min,max)
dim rand
rand = Int((max-min+1)*Rnd+min)
Response.Write(rand)
End Function

Function RandomDate()
dim M
dim D
dim Y
dim randdate
M = RandomNumber(1,12)
If M <2 OR M <4 OR M <6 OR M <9 OR M <11 Then
D = RandomNumber(1,31)
ElseIf M <2 Then
D = RandomNumber(1,30)
ElseIf M = 2 Then
D = RandomNumber(1,28)
End If
Y = RandomNumber(2005,2007)
randdate = M & "/" & D & "/" & Y
Response.Write(randdate)
End Function

For i = 1 to 500
varRandomDate = RandomDate()
End If

Thanks!
Drew
Jul 17 '07 #1
2 2344
Drew wrote:
I am trying to build a page to generate some random data for a
database that I am working on... I thought this would be simple, but
it has proven to be more difficult... I am trying to create some
functions to build a random date. It keeps returning a string like,
"9172006//" instead of "9/17/2006". What's making this do that?
Your RandomNumber function isn't returning anything.
Function RandomNumber(min,max)
dim rand
rand = Int((max-min+1)*Rnd+min)
Response.Write(rand)
RandomNumber = rand
End Function
Neither is the RandomDate function. Same problem
Writing to Response does not cause the value to be returned to the calling
procedure.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 17 '07 #2
Bob Barrows [MVP] wrote on 18 jul 2007 in
microsoft.public.inetserver.asp.general:
Drew wrote:
>I am trying to build a page to generate some random data for a
database that I am working on... I thought this would be simple, but
it has proven to be more difficult... I am trying to create some
functions to build a random date. It keeps returning a string like,
"9172006//" instead of "9/17/2006". What's making this do that?
Your RandomNumber function isn't returning anything.
>Function RandomNumber(min,max)
dim rand
rand = Int((max-min+1)*Rnd+min)
Response.Write(rand)
RandomNumber = rand
>End Function

Neither is the RandomDate function. Same problem
Writing to Response does not cause the value to be returned to the
calling procedure.

Randomize

Initializes the random-number generator.

Randomize uses number to initialize the Rnd function's random-number
generator, giving it a new seed value. If you omit number, the value
returned by the system timer is used as the new seed value.

If Randomize is not used, the Rnd function (with no arguments) uses the
same number as a seed the first time it is called, and thereafter uses
the last generated number as a seed value.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Derek Hart | last post: by
7 posts views Thread by Pablo J Royo | last post: by
14 posts views Thread by lutorm | last post: by
2 posts views Thread by Gregor Horvath | last post: by
9 posts views Thread by cmk128 | last post: by
6 posts views Thread by Matthew Cook | last post: by
26 posts views Thread by aruna.mysore | last post: by
13 posts views Thread by Sri Harsha Dandibhotla | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.