VB icon

Using the Dictionary Object in a Lotto Game

Email
Submitted on: 3/14/2019 7:13:40 PM
By: A_X_O 
Level: Beginner
User Rating: Unrated
Compatibility: VbScript (browser/client side)
Views: 301
 
     Very simple Lotto Game using the Dictionary Object. The game chooses 6 numbers from 1 - 59 Stores the numbers in the Dictionary Object then checks the numbers for Duplicates. Runs the Game again if Duplicates are found.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Using the Dictionary Object in a Lotto Game
' Description:Very simple Lotto Game using the Dictionary Object. The game chooses 6 numbers from 1 - 59 Stores the numbers in the Dictionary Object then checks the numbers for Duplicates. Runs the Game again if Duplicates are found.
' By: A_X_O
'**************************************

'------------------------------------------------------------------------------	'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'		Demonstration: Windows 10, VBScript; Dictionary Object		'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'										'
'	Purpose		:	Demonstrates Dictionary Object Checking Items	'
'	-----------------------------------------------------------------------	'
'	Creation Date	: 	14/03/2019 [dd/mm/yyyy]				'
'	Version		:	1.0						'
'	Designer	:	Fabian						'
'										'
'##############################################################################	'
'			MODIFICATION HISTORY					'
'------------------------------------------------------------------------------	'
'	Version		:	1:0	14/03/2019	Create the Sample	'
'										'
'------------------------------------------------------------------------------	'		
'
'
On Error Resume Next
'
Public Const StrTitle = "The Digital Lottery Game"
Public Const StrMsgTxt = "Here are your numbers"
Public Const StrBonMsgTxt = "This is your Lucky Bonus Number"
'
Dim IntLottoNumber
Dim IntLotto
Dim LottNumbers
Dim IntCounter
Dim TheDictionary 
Dim LngAllNumbers
Dim CheckNumbers
Dim IntItems
'
Set TheDictionary = CreateObject("Scripting.Dictionary")
'
Call StartGame()
'
Public Sub StartGame()
On Error Resume Next
'
For IntLotto = 1 To 6
'
Call RollTheDice()
'
Next
'
End Sub
'
Public Sub RollTheDice()
On Error Resume Next
'
Randomize 
'
	IntLottoNumber = Int((59 * Rnd) + 1)
'
 	CheckNumbers = TheDictionary.Items 
'
For IntItems = 0 To TheDictionary.Count -1 
'
If IntLottoNumber = CheckNumbers(IntItems) Then
'
Call StartGame()
'
Exit Sub
'
End If
'
Next
'
	TheDictionary.Add IntLotto, IntLottoNumber
'
End Sub
'
	LottNumbers = TheDictionary.Items 
' 
For IntCounter = 0 To TheDictionary.Count -1 
'
If IntCounter > 4 Then
'
	LngAllNumbers = LngAllNumbers & StrBonMsgTxt & Space(1) & "[" & Space(1) & LottNumbers(IntCounter) & Space(1) & "]"
'
Else
'
	LngAllNumbers = LngAllNumbers & LottNumbers(IntCounter) & "," & Chr(32) & Chr(32)
'
End If
'
Next
'
	LngLottoNumbers = InputBox(StrMsgTxt, StrTitle, LngAllNumbers) 
'
'


Other 17 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.