473,549 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(mi n,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(20 05,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 2390
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(mi n,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.publi c.inetserver.as p.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(mi n,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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
14009
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return value of a function acts like 'by Val' returning the value only (except for objects) can you make it return a reference instead? cheers, Krackers
9
3677
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people discuss how reflection does this, but I cannot find the syntax to do this. I have tried several code example off of gotdotnet and other articles. Can...
7
20337
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But , for example, when the file doesnt exists, i should not return any reference to a bad constructed object, so i need something as a NULL reference...
14
1861
by: lutorm | last post by:
Hi, I'm having a problem with a return statement being parsed to return a function (I think). Check here: template <typename T> class A {}; template <typename T> class maker_of_A { public: A<T>& make_A() {return A<T>();}; };
2
6001
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C language syntax itself. Thank you!
2
3286
by: Gregor Horvath | last post by:
Hi, Is there a possibility to format a log message to give the function name where the log appears? Example import logging def aTestFunction():
9
5063
by: cmk128 | last post by:
Hi Why put * in front of the function name in the declaration? int (*write)(struct inode *, struct file *, const char *, int); thanks from Peter (cmk128@hotmail.com)
6
2578
by: Matthew Cook | last post by:
I would like to overload the unary minus operator so that I can negate an instance of a class and pass that instance to a function without creating an explicit temporary variable. Here is an example: #include <iostream> using namespace std; class Object { public:
26
4830
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure about the syntax of calling the same. #include <stdio.h> void fp1()
13
1956
by: Sri Harsha Dandibhotla | last post by:
Hello all. I recently came across a function declaration as : char(*(*x()))(); This was not in some code but it was in a C questions thread on some group. I tried to decipher what it returns but couldn't make complete sense out of it. Can someone please explain what this function is supposed to return and expand it step by step. Thanks,
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.