Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2006, 01:45 PM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default HOW TO COMPARE NUMBERS IN VB, PLEASE HELP

Hi i am trying to make a lottery program , i got the program to show 7 numbers 1-49 and als made sure that the are not the same, but can someone give me the code for the checking the number the user has input. for expamle if user inputs 1,25,45,49,41,47 , i need the code for the program to check if it the same as the ones genrated , if the user get 3 number i message comes up saying you won £10 , if 5 number come up then message comes saying you won £2000.
I aslo need the genarated number to stored somewere so that , you can check the number from pervoius genrated numbers for up 5weeks.
i am soory i am new to this so can someone please help.

here is the code i got so far.

Private Sub cmdChoose_Click()
Dim arrNumber(1 To 6) As Integer ' Array
Dim intLucky As Integer ' Random Number
Dim intCount As Integer ' Selection Counter
Dim intCheck As Integer ' Previous Selection Counter

For intCount = 1 To 6 ' Select Six Numbers
Start: ' Start Point
Randomize (Timer) ' Seed Randomiser
intLucky = Int((49 * Rnd) + 1) ' Random number 1 to 49
For intCheck = 1 To 6
If intLucky = arrNumber(intCheck) Then
GoTo Start 'If selected number already present, select again
End If
Next intCheck
arrNumber(intCount) = intLucky ' Store selected number in array
lblNumber(intCount - 1) = arrNumber(intCount) ' apply selection to labels
Next intCount
End Sub

Private Sub cmdQuit_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 0 To 5

 
Old June 24th, 2006, 09:52 AM
Authorized User
 
Join Date: Jun 2006
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Default

Yes certainly. Store the user-entered numbers in six created variables (Bytes would suffice) Then just compare each number with each of the generated numbers using 'if' statements e.g If user1 = lotto1 then ..... etc. As for variables holding stored numbers after the machine is switched off, I suggest you transfer the numbers to constants at the end of each week's 'draw'.






Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net - Access DB - Date compare johneecc VB How-To 4 August 7th, 2008 04:23 PM
Formatting numbers in vb.net mallikalapati .NET Framework 2.0 3 February 20th, 2008 07:29 AM
Compare numbers and letters in same cell EricB123 Excel VBA 1 January 21st, 2007 03:30 PM
VB Numbers Mebbage XSLT 1 January 24th, 2005 06:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.