Tracker
 ASP PHP JavaScripts MySQL MS Access MSSQL VISUAL BASIC Subjects/Titles Post Text/Content
HOME    TRACKER    Visual Basic

# Generating Random Numbers, But Not Repeating Any, Is There An Easy Way To Do This?

## How can I generate random numbers but not repeat any that have already been generated. Is there an easy way to do this at all?Thanks!Eric

Random Numbers Repeating...
For a school project i have to get random numbers for 1 to 75 and display 25 of the random numbers, but without any repeating....so i need to know how you make it so the no number repeats itself when displayed...

Repeating Random Numbers
I want to create a function that creates 4 random numbers. but I want it so if i use the same value in the seed i always get the same numbers. This is the code that i thought would work...

Code:
Sub testRandoms(seed As Long)
Randomize seed

For i = 0 To 3
Debug.Print Rnd(1)
Next i
End Sub

calling "testRandoms 2000" i get

0.8549716
0.2907182
0.1909369
0.3054054

calling "testRandoms 2000" again, i get
0.8630618
0.4922775
0.1587687
0.9343805

they're not the same!!!!
what am i doing wrong?

28 Non Repeating Random Numbers And Freezing
I need to make a matching game for a project. I have the game itself all made and it works good. Now I need to make the placement of the cards random. I have 28 "cards" therefore 28 random non repeating numbers. 1-28. I have them on a timer all making seperate random numbers, and if the number made is equal to any numbers made before it, it will goto the begining of it's own seperate number randomizing code. But when I try to play it, just to see if it doesn't freeze, it does. Any help on a way to obtain my goal would be much appreciated.

PS, i need to be able to return back to the numbers, (like if num1 = 1 then image1.top = a number...and so on, so listing them in an array wouldnt work, least i dont know how to make it work like that.)

Thanx

How Do I Create Random But NO Repeating Numbers??
Hi,

I am using an array of 6 Text Boxes and In thoughs boxes I need 6 Numbers to appear.

The Numbers are from 1-49.

How do I get these numbers to be Random and make sure they are NOT repeated In any of the OTHER Boxes??

Thanks to ANYONE who can help Me on this.

Bye

Generate Random Numbers Without Repeating
I need to generate random numbers, from 1 to 15. The program runs a timer, and every second, a new number is generated, but it cannot be one that was already generated. This means that by time the 15th number is reached, it will be automatically chosen.

I have created a way of doing this involving 15 extra variables that are filled when each number is used. It works, but it seems to bog down the timer, since it is checking so many variables. Is there a simpler way of doing this?

Thanks,
Jason

Generating Random Numbers
I was wondering if anyone knew how to create a random number generater that would symbolize a deck of cards. I alread know how to generate the 52 numbers nut i don't know how to make the program use each number only once.

Generating A Set Of Random Numbers
i would like to know how to generate random numbers between two set numbers. For example, 0-999.

Any ideas?

Thanks,

Sam

Generating Random Numbers In VB6
For a project I have currently done, I have designed a database that contains a table, which contains the field "NHS Number". People in the UK would know that this is a unique ten digit number.

I am in the process of adding "people" into the database for testing purposes.

In real life, different people would have totally different NHS Numbers, so using AutoNumber is totally out of the question. So I have to have a random number...

I have currently made a random integer generator to solve this problem... or so I thought

Using the following code:

vb Code:
Private Sub Command1_Click()    Dim dblRand As Double    Dim strRand As String    dblRand = Int(Rnd * 10000000000#)    Text1.Text = dblRand    Clipboard.Clear    strRand = dblRand    Clipboard.SetText strRandEnd Sub

Using the
Code:
Int()
command doesn't acutally generate a random number each time for me. While I'm running the program, it generates random numbers, fair enough. When I start the program again, it generates the same random numbers it did before

Is there something I've done wrong? Is there another way to randomise numbers?

Thanks

Generating Random Numbers
I am fairly new to vb. But I dont know how to go about this problem. What I need is to Generate Random Numbers between 0 and 1. Numbers cant be more than 3 decimal places (.000).

I need help on this ASAP. So if anyone can shed some light on this, it would be great.

If you can provide code it would be even better.

Generating Random Numbers
In the Program I am Writing I need to have the ability to generate random numbers... Mainly 1-100 right now I used this

per1.Text = Int(Rnd * 100)

But it does not generate a very random number beig each time i run the program it runs the same numbers...
ButI also need to know how to generate random numbers for other TYPES of dice.. Such as a D3 D6 D10 and d20 But I do not even know where to start generating these? if anyone can give me a step in the right direction........

TIA
Rogan

Generating Random Numbers
How does one go about generating a random number in VB? I'm interested in knowing how to generate one in two scenarios:

Generate random # between 1 and 298
Generate random # between 0 and infinity

Generating Non-Linear Random Numbers
I need to create random data but not on a linear scale. For example, I want random data to show how many TVs are in a household. For this example the range I am working on is 1 to 11. I could use:

randomValue = Int(Rnd * 11) + 1

But I want the random results to be based on a percentage. For this example (see below), when I create my data, I want 4% of housholds to have 1 TV, 8% to have 2 TVs, 12% have 3% and so on...

14%
28%
312%
420%
523%
613%
711%
83%
93%
102%
111%

How can I generate this? There is probably already an example here for this, but I do not know what it is called to be able to search for it.

Thank you.

Generating Random Numbers For The Lottery
Someone was asking recently abount generating random numbers for the lottery. Here's the code...

I've commented it as best I can, but if you've any questions, let me know...
_____________________________________________________________
Option Explicit

'1. Select 6 random numbers from 42
'2. Sort them
'3. if any numbers are the same, select a random number to replace them
'4. repeat steps 2 & 3 until all numbers are different

'When debugging this code, set ArraySize to a large number (say 25), so
'you'll get lots of duplicates and so testing will be easier.

Sub Main()

Dim i As Integer
Dim NumberString As String
Dim temp1 As Integer
Dim Sorted As Boolean

Const ArraySize = 6 'Choose this amount of numbers from TotalNumbers...
Const TotalNumbers = 42 'Choose from these numbers...

Dim arrRandom(1 To ArraySize) As Integer

Randomize
For i = 1 To ArraySize
arrRandom(i) = Int(Rnd * TotalNumbers) + 1
Next i

Sorted = False

'The nested while loop is not wholly necessary for the program to work.
'You can take it out. The reason I've included it is for efficiency -
'when the nested while finishes, the numbers will be sorted, ready for
'comparison. If the nested while loop were excluded, the test for
'duplicates would not be comparing values from a sorted array and would
'therefore be pointless.
'But if you can come up with a nicer way of doing it...
While Sorted = False

'Sort the array in ascending order
'The logic here assumes that if one swap is made, the array is not
'sorted, so it goes back to the top and sorts again. When no swaps
'are made, the Sorted variable will be true and the loop will end.
While Sorted = False
Sorted = True
For i = 1 To UBound(arrRandom) - 1
If arrRandom(i) > arrRandom(i + 1) Then
temp1 = arrRandom(i)
arrRandom(i) = arrRandom(i + 1)
arrRandom(i + 1) = temp1
Sorted = False
End If
Next i
Wend

'Check for duplicates - if there are any, replace them with another
'random number. When the for loop finishes, we need to sort again,
'at which point we go back to the top of the while loop.
For i = 1 To UBound(arrRandom) - 1
If arrRandom(i) = arrRandom(i + 1) Then
arrRandom(i) = Int(Rnd * 42) + 1
Sorted = False
End If
Next i

Wend

'Output the chosen numbers via a message box
NumberString = arrRandom(1)
For i = 2 To UBound(arrRandom)
NumberString = NumberString & ", " & arrRandom(i)
Next i
MsgBox NumberString

End Sub

Excluding Numbers From Random Generating
Good day!
I develop a random number generator. I need to generate, for example, numbers from 1 to 90. How can I exclude from generating such numbers, like, for example, 89,76,2 and 7. How can I do that? What I was doing is adding each new generated number to a collection of restricted numbers, so if such a number appears, it generates another one and so on until all numbers are generated. But the presented algorithm is not the optimal one I think. Any ideas on how to implement the functionality?
Thanks!

Generating Random 4 Letters And/or Numbers
Hello,

How can I make my program generate a random combination of letters and numbers and display them in a textbox?

Generating Sequence Of Random Numbers
Hi everybody,
I want to generate sequence of numbers without repetition.
How can I do this?

Regards,
Saeed

Generating Random Numbers, Whole Numbers Only
hello all!

I used this code to generate random numbers in VB:
Code:lRndNum = (65000 * Rnd)

where I wanted to produce a bunch of random numbers from 0 to 65000.
My problem is, I want to discard the decimal points in the generated random result.

I only want to have random numbers, whole numbers, that is, without the messy decimal point.

I hope you'll hear me out. Thanks!

Problem In Generating Distinct Random Numbers
i am using this below code to generate random numbers
g=cint(rnd*10)+1
msgbox g
but some time repeating random numbers occurs like when i click
command button msgbox giving 6 and when i click command button IInd time msgbox giving 4 and for IIIrd time it is once again
giving 6 this is what i want to prevent, how can i prevent this.

Array Help (generating Unique Random Numbers)
ok the problem i have is i want 6 random numbers to be generated inside 6 text boxes i then want the 6 boxes to be checked so they dont have

Code:

spent = spent + "1"
lblSpent = ("£" & spent)

For x = 0 To 10

ball(x) = Int(Rnd() * 10) + 1

Next x

For x = 0 To 5

lblResult(x) = ball(x)
Next x

lstWinningNums.AddItem (lblResult(0) & " " & lblResult(1) & " " & lblResult(2) & " " & lblResult(3) & " " & lblResult(4) & " " & lblResult(5))

that happily givs me mynumbers, so how do i use an array to check each box for the same numbers then get it to genrate a new number

[easy] Generating A Random String From An Array
Here's a very simple question with a probably very simple answer..

I made a form with a CommandButton1 and a TextBox1 in VB 6.3. This is what I want to make happen: click the CommandButton1 -> make appear a string in TextBox1, randomly chosen from an array consisting of these three words 'apple', 'pear', 'banana'. This should be completely random, eg. clicking the button 5 times in a row may give an output sequence like this: banana - pear - banana - apple - apple.

That's really all the code should do From there I can work on my project myself.

(there doesn't seem to exist many good free VB tutorials online, and the book I got from the library down town isn't of much use either..)

Who can help me out? Should be a quickie!

Non-repeating Random No&#039;s
Apart from being a complete beginner with VB, I would like to know how to generate a group of 6 random numbers (displayed in 6 labels) with none of those numbers being the same.

I am already aware of the Int(RND * 49)+1 code line that creates a random number between 1 and 49. How can i get non-repeating numbers in my question above?

Repeating Numbers
how do I get visual basic to ignore the fact that "1/6" is a repeating number... basically, I want to multiply "1/6" six times to equal 6, but it keeps giving me "1.0000000000000000" blah blah blah. How can i have it make a clean "1"?

thanks!

Repeating Numbers
Do anyone have any code that could tell if a series of nine numbers are repeating? I am checking to see if a SSN is all repeating numbers. For example, a person's SSN is 999999999.

Thanks
Shannon

Random Numbers-is It Possible To Generate Random Numbers With A Algorithum?
The rnd function in vb generated pseudo-random numbers. That means if you use these numbers as a key for some type of encryption it would make it fairly easy to break(if you knwo how) because you can predict what numbers will be generated by the rnd function.

I'm trying to design a method that might involve a couple of diffrent algorithums to genertae random numbers.
One of my idea's was to monitor network traffic for numbers, error messages, etc...
At the moment I have absolutely know idea howto monitor the arrival of packets or error messages, so if you knwo how please respond!!!

Generate Random Names Without Repeating That Name Again!!!!
What code is needed to stop generating the same name over and over again, becasue i want it to randomly generate the name once and then choose another. YOUR HELP WILL BE A PRECIATED

Non-repeating Psuedo Random Number Generators
I use this from time to time and just thought I'd share it...

Code:
'=========================================================================================
' Random Number Functions
' by Mark R Hamner (maxhamner (at) hotmail.com)
'=========================================================================================

Private rnd_PR8 As Byte
Private rnd_PR16 As Long

'=========================================================================================
' PSEUDO RANDOM NON REPEATING
' These routines generate a fixed pattern, BUT, they generate every value in a range
' ONE time before it repeats. This effect is very useful for pixel fades because if
' you use the value to determine a pixel to draw (or erase) it will generate all the
' values only 1 time, meaning all pixels will be addressed without testing or maintaining
' an array. Applications are limited, but VERY useful in specific cases.
'
' Call routine once passing a seed value, then
' Call it without a value to get successive pseudo random values
'
' NOTE: The value 0 will not be generated, but can be used as a seed.
'
' This method was originally in a Dr Dobbs journal in the mid 80's, along with a table
' of mask values that would generate various ranges. I have used this routine 100s of
' times in assembly for various graphics effects (like pixel fades for older palm pilots)
' and converted it to VB to use for a 'block' fade effct (bitblt blocks, not pixels)
' and thought someone might find a good use for it.
'
' If anyone has a copy of the original article please email it to maxhamner (AT) hotmail.com
'=========================================================================================

' This generates a pseudo random 8 bit (1-256) value
Public Function rnd_pseudo8(Optional myval As Byte)
If IsNumeric(myval) And (myval <> 0) Then rnd_PR8 = myval
carry = ShiftRight(rnd_PR8)
If carry Then rnd_PR8 = rnd_PR8 Xor 184 '0b8h
rnd_pseudo8 = rnd_PR8
End Function

Public Function rnd_pseudo16(Optional myval As Integer)
If IsNumeric(myval) And (myval <> 0) Then rnd_PR16 = myval
carry = ShiftRight(rnd_PR16)
If carry Then rnd_PR16 = rnd_PR16 Xor Int(46080) '0b400h
rnd_pseudo16 = rnd_PR16
End Function

'------------------------------------------------------------------------------
Private Function ShiftRight(ByRef myval) As Boolean
Dim result As Variant
result = myval / 2
myval = Int(result)
If Int(result) <> result Then ShiftRight = True Else ShiftRight = False
End Function

-max
maxhamner aht hotmail daught com

APIs are not an ADD-ON to VB, they are its FOUNDATION.

I Can't Stop Repeating, Repeating,repeating,repeating,repea . . .
I have a function which adds together three integers from an array in a loop. It tests for TRUE and puts the result in another array. Thus: A+B+C=X.
I would like to filter same results, for example if we want X=10 then 5+2+3=10 or 5+1+4=10 but there is no need to repeat 2+3+5=10.

Here's what I got so far:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function Combine(Values, TargetValue) As String()

Dim arr1, arr2, arr3
arr1 = rArray
arr2 = rArray
arr3 = rArray
Dim i As Integer, j As Integer, k As Integer
Dim arr() As String
For i = 0 To UBound(arr1)
For j = 0 To UBound(arr2)
For k = 0 To UBound(arr3)
If arr1(i) + arr2(j) + arr3(k) = intVal Then
arr = AddToArray(arr, arr1(i) & " + " & arr2(j) & " + " & arr3(k) & " = " & intVal)
End If
Next k
Next j
Next i
Combine = arr

End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub cmdRes3_Click()

On Error Resume Next
intVal = txtVal.Text
Dim arr() As String
Dim i As Integer
arr = Combine(rArray, 10)
txtAns = "" 'clear textbox
For i = 0 To UBound(arr) - 1
'Debug.Print arr(i)
txtAns = txtAns & arr(i) & vbCrLf
Next 'multi dimensional

NoGood_click ' combination error

End Sub

Obviously I left out a lot of code but I had wanted to show the general idea.

How Do I Make A Loop Instead Of Repeating Commands? (super Easy!)

Path1 = "E:logsslhe"
Path2 = "E:logsportalAU_PortalIntranet_3"
Path3 = "E:logsportalAU_PortalIntranet_4"
Path4 = "E:logsportalCHAPPS02"

Dim fso
Dim oFolder
Dim oFile
Dim oSubFolder

Set fso = createobject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder(Path1)

For Each oFile In oFolder.files
If DateDiff("d", oFile.DateLastModified,Now) > 100 Then
oFile.Delete True
End If
Next

Set fso = createobject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder(Path2)

For Each oFile In oFolder.files
If DateDiff("d", oFile.DateLastModified,Now) > 100 Then
oFile.Delete True
End If
Next

Set fso = createobject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder(Path3)

For Each oFile In oFolder.files
If DateDiff("d", oFile.DateLastModified,Now) > 100 Then
oFile.Delete True
End If
Next

Set fso = createobject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder(Path4)

For Each oFile In oFolder.files
If DateDiff("d", oFile.DateLastModified,Now) > 100 Then
oFile.Delete True
End If
Next

and so on forever and ever how can I make it into a simple loop instead to make my program easier to maintain? Something like what you see below.. where it will just loop through all the different paths that I define up top.

Or better yet how would I say go into directory A, get all the subdirectories, and then loop through all of them? That part I don't need right now.. just the basic part.

Set fso = createobject("Scripting.FileSystemObject")

Set oFolder = fso.GetFolder(Path1/2/3/4/5/etc)

For Each oFile In oFolder.files
If DateDiff("d", oFile.DateLastModified,Now) > 100 Then
oFile.Delete True
End If
Next

The Random Function Gets The Same Random Numbers Every Time I Start The Program
I'm making a Poker program

The code is like:
Command1_click sub()
Card1.caption = int(rnd()*53) +1
Card2.caption = int(rnd()*53) +1
Card3.caption = int(rnd()*53) +1
Card4.caption = int(rnd()*53) +1
Card5.caption = int(rnd()*53) +1
End sub
( I use much more codes of course)

When I click the command1 button, I get the numbers random, but I get the same random numbers in the same order every time I start the game.
Example.

I start the game:
I click command1: card1= 9, card2= 18, card3= 42, card4= 23, card5= 4
I click command1 again: card1= 7, card2= 51, card3= 13, card4= 29, card5= 14
and so on, random every time I click...

I start the game again, another time:
I click command1: card1= 9, card2= 18, card3= 42, card4= 23, card5= 4
I click command1 again: card1= 7, card2= 51, card3= 13, card4= 29, card5= 14
and so on, random every time I click. But I get the same numbers, In the same order.

I hope I've explained my problem well.

Random Generating
i am creating a program that i want to simulate a bit test with. so if i click on label.caption i want label14.caption to to go from the caption "bite" to a 5 sec delay during which it will display "bite in progress" and after the time period of 5 sec i want label14.caption to select at random a fault from a list i specify.

Generating A Random
Hello, i have a playlist editor for an MP3 player and would like to have a random song play function. I know how it would work but not sure about the code required to generate the random number values. I would need code to fetch how many entries there are in the listbox, then some code the generate a randon listindex number, any ideas?

Generating DIFFERENT Numbers
I have a prog wich generates some random numbers.
How do i make sure that all my random generated numbers are different numbers?

Code:
Private Sub Command1_Click()
Dim i As Single
Dim a(0 To 6) As Double
Dim RandomNumber As Double

For i = 0 To 6
RandomNumber = Int(Rnd() * 42) + 1
a(i) = RandomNumber
Label(i).Caption = a(i)
Next i
End Sub

Generating Numbers
I was wondering what the best way to generate a list of numbers in the range of 0000 - 5000 would be? I tried looping, but I cannot loop through more than one 0 at a time.

For example, if I do this:

Code:
Dim NumLoop As Integer
NumLoop = 0000
Visual Basic will reset "0000" to just a single 0. So, how can I generate numbers from 0000 - 5000 easily?

Generating Numbers!!
Hi!

I am trying to generate some numbers as follows:

From: 00000000001
To: 99999999999

Well the problem is when i try to do it using a loop or something as soon as i press enter or space after typing the number 00000000001 VB converts it to 1 automatically.

And the other problem is that when i type in a big number like this VB automatically adds a '#' sign after the number! i don't know what it means but then i am unable to generate the numbers.

Any solutions ?

Thanks!

Generating Possible Numbers
Ok what i want to do is here is a picture those 6 boxes the user inputs numbers say 1-50 in each box then when they click generate possible numbers meaning combinations label on the right tells them how many and the big textbox multilined tells them all the possible numbers dashed can yall help me out?<p>

Generating Numbers..
Hmm, not sure how to put this really.. I wanna know if it's possible to generate a WHOLE list of the possible combinations you can make using 0-9.. An I want it to remove doubles if there are any.. Is there ANYWAY at all this coule be done?

Generating Numbers
OK, I have 9 labels, in which I want to display 9 numbers,
from 1-9.

Now, I need to display each combination of possible numbers, in a methodical way, using a timer, where each time it fires, a new set of numbers appears.

Any ideas?

Thanks,
Jez

Generating A Random Dungeon Map...
Programming slashers are pretty fun. Playing them are fun too. The one thing I have found that makes the games old quickly is "static maps".

I've done a few games with great "map editors", but after a while, creating "new maps" get's to be a pain and, besides, if you create the map yourself... where's the adventure in that?

About the most famous of ALL games in which has random map generators is Diablo 1 & 2. I guess that's why those games stay popular for so many years... the maps are always different for each game.

In doing this, I have discovered it's no easy task to "do a good map everytime".

Plain "Map editors" are easy and aren't much of a challenge. I'm looking for something to make a game engine that will keep interest.

I've done a couple of generators, but the results are no where near satisfying.

I am wondering if there is anyone here who has successfully coded a Random Map Generator?

I'm NOT looking for code... What I am looking for is "approach", or flow of your code.

I'm starting with simple maps. 2D Square Dungeon maps. Rooms and Hallways and Doors.

My approach is starting top left, doing 1 square at a time. Do some logic on the surrounding squares, make a decision on what to make that square, move on to the next.

The problem is there isn't much structure to the map.

How would you do it? Generate Hallways for the Map, then fill in the spaces with Room, then Doors?
Or, Generate Rooms throughout the map, then fill in with hallways?
...etc.

Just looking for some Code "FLOW" ideas.

Thanks!

Generating A Random Number
Hi,

How to create a random number between 30000 and 40000 ?

Generating A Random Number Between 1 And 10
What code can I use to generate a random number between 1 and 10. This is how it is gonna work... I have 10 quetions for my users:

Question1
Question2
Question3
Question4
Question5
Question6
Question7
Question8
Question9
Question10

and I need to generate 5 random numbers between 1 and 10. These random numbers will decide which 5 questions my program will ask them. so if one of the random numbers is 3 it will ask them question 3. Any ideas how I can do this?

Generating 7 DIFFERENT Random Integers
I need to generate 7 integers between 1 and 7 that are all different. Thanks.

By the way... This is the code I have so far (will only genertae the numbers, not make sure they are different)

Code:

Randomize()
z = Int(Rnd() * 7) + 1
y = Int(Rnd() * 7) + 1
x = Int(Rnd() * 7) + 1
w = Int(Rnd() * 7) + 1
v = Int(Rnd() * 7) + 1
u = Int(Rnd() * 7) + 1
t = Int(Rnd() * 7) + 1

[HELP] Generating Random Filenames
Hello there. I need some help generating random filenames.

I have tried:

Code:
Dim 1 As String
Dim 2 As String
dim 3 As String
3 = randomnumber
2 = ".ini"
1 = App.Path & "" & "3" & Extension
Print #1, "#Account DO-NOT-CHANGE-ANYTHING-HERE"
Close #1

Something like that, but the file wont save, and gives me an error. Can someone please help?

Generating Random Pictures
Ok, So i have a big picture box on a form which will work as the battle background for a turn based game I am making. I want it to load one of the random backdrop pictures i have on form load.

So heres the code I have made so far, but it does not seem to work. This is important because I dont want to have the same background on every fight and im not using multi forms just to battle with different backdrops.

Someone help

Code:
Const MAX_BACKGROUND As Integer = 10
Dim bgArray(MAX_BACKGROUND - 1) As String

InitBackground
SelectBackground
'This just displays a name they entered
nameShow.Caption = ReadINI("config", "CharName", App.Path & "config.ini")
End Sub

Private Sub InitBackground()
bgArray(0) = "backdrop1.jpg"
bgArray(1) = "backdrop2.jpg"
bgArray(2) = "backdrop3.jpg"
bgArray(3) = "backdrop3.jpg"
bgArray(4) = "backdrop3.jpg"
bgArray(5) = "backdrop3.jpg"
bgArray(6) = "backdrop3.jpg"
bgArray(7) = "backdrop3.jpg"
bgArray(8) = "backdrop3.jpg"
bgArray(9) = "backdrop3.jpg"
End Sub

Private Sub SelectBackground()
Dim RandomNumber As Integer
RandomNumber = Random(0, MAX_BACKGROUND)

Dim curPath As String
curPath = "graphics"

End Sub

Function Random(Lowerbound As Long, Upperbound As Long)
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound
End Function

Help Generating A Random Number [vb 6]
hello

im looking for the old way of generating a random number, linking it to a variable. I remember it being something quite simple but i cant remember the exact code for it

thanks

Generating Random Letters In Vb 6.0
Hi all

Sorry should have explained this in more detail, here's what I want to do.
I have one form with 5 text boxes on it and need to generate random letters between A-F and random Numbers between 0-9

For Example: Text box 1 A0, Text 2 B7 Text 3 F9 Text 4 C6 Text 5 E8

So when the user clicks the command button, the program will generate random letters and numbers in each of the text boxes.

Could anyone maybe just point me in the direction with a couple of lines of code to perform this task.

Thanks for any help in advance

Cheers,
Steptoe

Generating A Random Number?
Is there anyway to make VB generate a random number.
eg.
Integer = Random(0,200)
so it would pick a number between 0 and 200

Generating Random Letters
Okay, here's a couple questions that should be pretty easy to answer. First, how can I generate random letters? And since I haven't really used loops before in the stuff I've made, how can I make a loop so that the program continuously just generates these random letters over and over? Or perhaps a timer would be involved? These should be simple but I'm just not sure how to do it right.

Generating Random Strings?
I want to make a simple little app where you click a command button and it puts random text into a text box. So how can i set some text as a string and randomize it upon the command button click?

E.G:

I have these strings

This is a random text string 1
And so is this but random 2
I am also a random text string 3
I might be lucky and randomly picked to be put in the text box

If you get what i mean, now on the command button click one of the above strings are selected.

THANKS!

Generating Random Number
Hi everybody,

Anyone knows how to generating Random Integer Number beetwen 1 to 1000 ?