To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Feb 11th, 2007, 07:08 AM   #1
matt_adelaide
New Member
 
Join Date: Feb 07
Posts: 2
matt_adelaide is an unknown quantity at this point (<10)
random number generator to get an item from access

hi Everyone,

I am trying to write a programme for a membership draw. I have created a membership database with 360 members.

What I want to do is get VB to pick a random number from 1 to 360, then go to the database and then display what the field is located at that number.

I have created the database so that there is a "number Record" as the key.

ie if VB selects 60, I want VB to show what information is at record number 60.

I have looked through the forums for an answer, but cant quite find what I am looking for.

Hope someone can help
matt_adelaide is offline   Reply With Quote
Old Feb 11th, 2007, 07:11 AM   #2
cssriraman
Frenzied Member
 
cssriraman's Avatar
 
Join Date: Jun 05
Posts: 1,465
cssriraman has a spectacular aura about (125+)cssriraman has a spectacular aura about (125+)
Re: random number generator to get an item from access

Welcome to VB forums.

Checkout the link:

How to generate a random number, in between two given values
cssriraman is offline   Reply With Quote
Old Feb 11th, 2007, 07:12 AM   #3
cssriraman
Frenzied Member
 
cssriraman's Avatar
 
Join Date: Jun 05
Posts: 1,465
cssriraman has a spectacular aura about (125+)cssriraman has a spectacular aura about (125+)
Re: random number generator to get an item from access

what is your database structure?
cssriraman is offline   Reply With Quote
Old Feb 11th, 2007, 07:24 AM   #4
matt_adelaide
New Member
 
Join Date: Feb 07
Posts: 2
matt_adelaide is an unknown quantity at this point (<10)
Re: random number generator to get an item from access

Database structure is:

Field 1 - Number
Field 2 - Surname
Field 3 - Given Name

All I need it to do is randomly select a number, then display first and given name
matt_adelaide is offline   Reply With Quote
Old Feb 11th, 2007, 08:59 AM   #5
the182guy
Frenzied Member
 
the182guy's Avatar
 
Join Date: Nov 05
Location: Cheshire, UK
Posts: 1,467
the182guy has a spectacular aura about (100+)the182guy has a spectacular aura about (100+)
Re: random number generator to get an item from access

Heres how to get a random between two values:

VB Code:
  1. Private Sub Command1_Click()
  2.     'get a random with 5 being the low, 10 being the high boundry
  3.     MsgBox GetRandom(5, 10)
  4. End Sub
  5. Private Sub Form_Load()
  6.     ' randomize to ensure it is random and
  7.     ' not the same sequence each time it runs
  8.     Randomize
  9. End Sub
  10. Public Function GetRandom(ByVal Low As Long, ByVal High As Long) As Long
  11.    
  12.     'This function takes a low and high and returns a random between them
  13.     GetRandom = CLng((High - Low + 1) * Rnd + Low)
  14. End Function

@cssriraman that function you posted returns a variant and tries to emulate a simple loop by using Goto labels!
__________________
Chris

Codebank: Easy Javascript Form Validation (OOP)

If this post helped please rate it!
the182guy is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:32 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.