Generate Random Number Between 1 & 5

I want to display a random banner from a selection of 5 banners. So if number = 1 then display baner 1 etc. My code is as follows:

bannerCount = bannerRecordSet.RecordCount
Dim bannerSelected
Randomize
bannerSelected = Int(Rnd * bannerCount)

The above code works although it never seems to generate the value 1, ie 2-5. Also when I refresh the page sometimes a random banner is displayed and other times I get an error. Is this because I am generating a value outside 1-5? Code:

View Replies


ADVERTISEMENT

Generate Random Number

I know this is not a php forum, but i've been given a task to create a form that requires a unique number every time the form is loaded. The form has been created but they have php on their site. windows would be in 3 weeks time but they want the form asap. The field is a hidden field since i've never looked at a php code page b4 i need some help.

View Replies View Related

Generate Three Random DIFFERENT #s

I'm trying to generate three random different numbers to display three images on a page without repeating them. I can't seem to be able to get them to always be different. There's probably some simple solution, but I can't figure it out.

Here's my current code: ....

View Replies View Related

Generate Random String

I need to be able to create some license keys for an application. Ideally
these wouldn't be too long in length (ie, easier to remember/type in), but I
would like them to be auto generated and a check made to see whether or not
that key has already been used, something which could generate up to about
10000 keys (or more if the string doesnt have to be too long) would be very
useful.

A combination of letters, numbers, upper and lower case is needed.

I could sit here and start plugging away at this, an array for numbers, an
array for letters, a random test for uppercase/lowercase etc, but it occured
to me that I'm probably just reinventing the wheel a bit here, someone must
have done this before!

Has anyone produced anything similar to this in the past?

View Replies View Related

Generate Random Numbers Between 10 And 1,000,000

I am trying to create a random value between 10 and 1,000,000. I am using the following code but it is creating numbers between 10,000 and 999,999. How can I fix it.

<%
Highest=1000000
Lowest=10
Randomize
Val_Rand=CStr(CLng((Highest-Lowest+1)*Rnd+Lowest))
response.write(val_rand)
%>

The code never gives small numbers like 10, 15 500, 250, 257 etc.

View Replies View Related

How To Generate A Random Time In VBScript?

Any clues or ideas how to generate a random time in VBScript?

View Replies View Related

Generate A Number

I want to prepopulate a ticket number in my form, like when user enters the form the field ticket Id should always be filled with a number. I want to start my number with 1000.

View Replies View Related

Generate / Increment Id Number

do anybody know how to write a code to increment id number in the text field once the "New" button is clicked in the form. Code:

View Replies View Related

Auto Generate Number

I want a sample code for developing an " auto genearte number " and want to store in database.

View Replies View Related

Generate Randomize Number

i trying to generate randomize number between in the range of 1 to 9999 using the below code. DNum* is between 1 - 9

RandValue = CLng((2^7*(ID1Num1))+(2^6*(ID1Num2))+(2^5*(ID1Num3 ))+(2^4*(ID1Num4))+(2^3*(ID1Num5))+(2^2*(ID1Num6)) +(2^1*(ID1Num7))+min1+min2+sec1+sec2)

then i put the randvalue where is usually generate number between 400-to-1500 into the below formula, any suggestion on how to improve the below code?

num_pmax = Int((9999 * Rnd) + 1)
num_pmin=1
value1 = Int((Num_pmax-Num_pmin+1)*Rnd+Num_pmin + RandValue)

View Replies View Related

Automatically Generate A Number

I am creating a Change Management system and need my ASP script to be able to generate a number as an incident number for example for me automatically. The number would be stored in a MySQL database and the language I am using is ASP.

Can I create a column in the database that is a Primary Key and is auto_increment, even if I have already got another coulumn that is the ID column, which is a primary key?

View Replies View Related

Random Number Not Random

I am trying to generate a random number. I am using randomize and then rnd to return a decimal number between 100 and 120. This will give me a longitude. I am doing something similar to generate a latitude.

I created this on a page which refreshs every minute. I put these points into a map and they are showing up in groups of straight lines. Since rnd is time based will refreshing every 60 seconds return similar numbers?

View Replies View Related

Random Number

trying to get a random number from 0000 to 9999, is there an easy way to do this? i'm using this for a unique filename and want it to be 4 digits from 0000 to 9999.

View Replies View Related

Random Number

x = ROUND((0.9+1.005*RND()-0.4),1)
y = INT(y * x)

This is what I'm trying to acheive:
- "Y" has a preset value between 1-100
- "X" should be random between 0.8 and 1.2
- "X * Y" is the final value of "Y" as a whole number

What I'm struggling with is getting the value of X to be random between 0.8 and 1.2....

View Replies View Related

Random Number

How would you go changing a random number generated into a item drawn from a database with SQL....

View Replies View Related

Random Number

I need to create a random number, or even better, and random combination of letters and numbers, to be used as a type of security key for changing a user's password on this site i'm working on. Basically, the user fills out this form which sends them and e-mail w/ instructions on how to change their password (pretty basic, lots of sites do it).

In the e-mail of course is a link which links to a page with querystring values that include their customer number, the action (reset password), and hopefully this "key." What I'd like to do is have the key written to a database when the e-mail is sent and then deleted when the password is changed. So, how can I generate this key. I think I can take care of the writing to/deleting from the database.

View Replies View Related

Random Number Problem

I'm trying to create a random number that has to solid letters at the beginning followed by 8 random numbers (DN13523781) This number also can't be in use alreaddy which means it can't alreaddy be in a colum called number in the database.

I can do the letters followed by one number, but I can't figure out how to get 8 numbers in a row without getting the same ones over and over(88888888)

I also don't know how to check if it's alreaddy used in the database.

Also does someone know how I can prevent the same number from being produced before it can be added to the database at an other location/pc.

I'm building an online store and I want to give people an order number when they order something. Code:

View Replies View Related

Random Number Function

Does anyone know of any parameters for either of these functions?
Say, if I wanted only numbers between 1 and 100?
Code:

<%
randomize()
response.write(rnd())
%>

View Replies View Related

Unique Random Number

How can I generate a unique random number?

View Replies View Related

0.7055475 Is Not A Random Number!

I've got a realy wierd server problem - everytime i ask for a random number using rnd() i get 0.7055475. This problem just appeared the other day. I hadnt changed any server or os settings, however i have recently recieved a 6 part xp pro update... - has anybody come accross this before?

View Replies View Related

ASP Random Number Generator?

Does anyone know how to code in a very simple random number generator?

Basically, my ASP site is linked to an SQL d/base. What I want to do is have a "Random quote of the day"... the R.N.G. should spit out a number, and that number references the random_quote_ID in the d/base and spits it out.

View Replies View Related

Assign A Random Number

I have this simple application that I put together using ASP. It has an html form that submits to an access database through a simple ASP file. It’s a survey form basically. One of the departments here wants to get some feedback from their students and in return for filling out the survey they will be entered into a drawing for a gift certificate. The catch is that the survey is anonymous. What they want to happen is each person is given a unique number at the end of the survey and they will pick one of those numbers randomly to see who the winner is. How can I possibly do this? I am stuck.

I think I may know what I need to do:

Pull a unique number from a database and post it onto the HTML form near the submit button. Notate on the page that the user write the number down and when they hit submit it is inserted into the database along with the record. I have absolutely no idea how to do that.

The HTML form submits into the database using this "add.asp" file:

Code: ....

View Replies View Related

Generating Random Number...

I've tried using javascript to rotate an image upon reload, but I can't get it working, so now I'm trying it with asp. I don't understand why this won't work. Any ideas? Code:

View Replies View Related

Random Number Generation

I want to create a random number where it concatenates with the "day counter" as explained below and name of the person inorder to generate a unique id.

by day counter i mean. there are 365 days in a year and today is the 18th day of the yeat. so the counter generated shud be 18&Smilesmita. How do i do this in ASP ?

View Replies View Related

Random GUID Type Number Or RegExp

I have used:

set typ = server.createobject("Scriptlet.TypeLib")

to create a random string of 36 characters. However, is there a way to
create a random string of digits in the length I request? Perhaps a string
of 20 digits with a few asterisks thrown in for ease of typing?

for example:
4515-81301-75454-45136-1

Would this be reated with RegExp? And how?

View Replies View Related

Test A Random Number For Nearby Numbers

not after code, just thoughts, suppose i'm generating a random 8-digit pin number for our clients, first i'll be checking against the db to see if it already exists before assigning it. what i might do for that is getstring all of the exsiting pins at the top of the script and just keep performing an instr until i get a 0. (i dont expect to ever go above a thousand clients for this system and hopefully my initial number will be random enough that these checks are for backup/redundancy assertion anyway)

but anyway, the main problem is: i dont want to generate a random pin that is one (or maybe two) digit(s) different from another,. i.e.

11111111 is too close to 14115111 and much too close to 11111811. 11121111 is right out of the question as it can be entered as a typo, as is 11111411 because of the numpad

so i'm after thoughts on how to perform that check, i suppose if i went with the "big string of all pins that went before" check i could perform a number of regex searches on the string. i.e.

my pin is 12345678 and i dont want ony to be one digit different so i'd check the string against .2345678 1.345678 12.45678 and so on. think i just answered my own question, anyone else got any ideas? especially for the two digit case (dont want to be performing 36 regex checks do i!)

View Replies View Related

How Do I Make Random Images Not Random?

However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it.

<%
limit=3
redim link(limit)
redim image (limit)

link(1)="xxx"
image(1)="image1.jpg"

link(2)="xxx"
image(2)="image2.jpg"

link(3)="xxx"
image(3)="image3.jpg"

randomize
random=int(rnd*limit)+1

%>
<center>
<a href="<%= link(random) %>">
<img src="<%= image(random) %>" border="0"></a>

View Replies View Related

Making It Random (getting Random Numbers)

I just wanted to know whats the best way to generate 50 or say X amount of number at random without having to repeat any of the previous number...

so far I've the following:

[VBS]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
function RandomNumber()
dim theRandom

Randomize
'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

theRandom= Int((99 - (0) + 1) * Rnd + (0))

if (theRandom<10) then theRandom = "0" & theRandom

RandomNumber = theRandom
end function
%>[/VBS]

and then I've this in the body of HTML doc: Code:

View Replies View Related

Random Token Generator - Not Really Random

We have the need to have a random token (a 16 char alphanumeric field) to be used as the key for one of our SQL tables. I have created a random token generator, however after only 3 months in production, it appears that we had an instance where a token that already existed in the tables was created. There are 3810 records currently in the database so it isn't like there are billions of records there.

I contacted an old college buddy of mine who is a mathematician, and he claims, assuming that random really does mean random, that the chances of getting a duplicate token are 1 in 79.5 septillion (79,500,000,000,000,000,000,000,000).

So my conclusion is that this was either a complete freak of nature occurance, or my random generator isn't really all that random. Here is the code behind how I am generating this: Code:

View Replies View Related

Convert Real Number Into Text Number

I need to insert some number into database as text. My problem is if I insert the number (ie. 4.0), the value in the database only show (4). So, is it possible to convert a real number into text number using ASP?

View Replies View Related

Sequential Number After Batch Number

here is the scenerio

in master batch table i have various master batch like
200701-0001
200701-0002
200701-0003

Now each master batch can have multiple final mixed batch like

200701-0001-01
200701-0001-02
200701-0001-03

and this record is inserted in to fmix table.

so i have a form in which i have a dropdown menu in which all the master batch is listed,
i select 200701-0001 and that value is passed to next page where i will enter other fields data and insertion to my fmix_no will be done automatic like 200701-0001-01, 200701-0001-02 and so on,

how to achieve this

so in short each master batch will have more than one final mixed batch.

pls help, also if u have any online contact in yahoo or msn pls send me, i am so confused and badly struck deadline is just couple of hours away. my yahoo id is(E-Mail address blocked: See forum rules) you can PM me i am online right now.

View Replies View Related

Retrieve The Error Number In VB With Err.Number

I want To handel the error messages by myself in one part in my script. I know that in VB I can Use the statment - On error resume next And I also know that I can retrive the Error Number In VB with Err.Number.

How can I handel the errors by myself in ASP? I heard about the ASPErr Object, Is it the same thing like the err object in VB?

View Replies View Related

Generate A New XML Doc

how I generate a new XML file that I can then use with an XSLT file. I am trying to use an XML file generated from Microsoft Project or even better generate an XML file from the project file (MPP File) itself. Which I can then use with an XSLT file

I am new to XML and want to create a project viewer using XML, ASP and XHTML. I have an idea of how this should work but would really appritiate any help someone can offer. Is it possible to take an XML file and generate it in ASP without using an XSLT file??

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved