Hi guys!
SOS - SOS - SOS
Time Sensitive: This assignment is due 11/15/2019 11:59pm
I'm lost on where to start:
Its a VISUAL BASIC Extra Credit assignment
Code must work in VB Studio 2017 or 2019 please :)
Its a "design your own" programming challenge from the book,
"Starting out with Visual Basic" (7th) Seventh Edition, Chapter 5 List & Loops P.377 or P.636 (PDF)
Thank you for the help and your time!
ASSIGNMENT:
Create an application that simulates rolling a pair of dice.
When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice.
Use PictureBox controls to display the dice. (In the student sample programs, in the Chap5 folder, you will find six images named Die1.bmp, Die2.bmp, Die3.bmp, Die4.bmp, Die5.bmp, and Die6.bmp, that you can use in the PictureBoxes.)
In case of any query do comment. Please rate answer as well. Thanks
Note: You put images path of your images in the code.
Code:
======from1.vb=======
Public Class Form1
Dim images As Dictionary(Of Integer, String)
Dim dice1 As New Random
Dim firstdiceNumber, secondDiceNumber As Integer
Private Sub btnRollDice_Click(sender As Object, e As EventArgs) Handles btnRollDice.Click
'roll a dice, generate an random number twice
firstdiceNumber = dice1.Next(1, 7)
secondDiceNumber = dice1.Next(1, 7)
'find the image path from the images dictionary
pcbFirstDie.ImageLocation = images(firstdiceNumber)
pcbSecondDie.ImageLocation = images(secondDiceNumber)
'load the images in the picture boxes
pcbFirstDie.Load()
pcbSecondDie.Load()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
images = New Dictionary(Of Integer, String)
'Fill the dictionary with the full images path, when dice rolls 1, pick the corresponding image
images.Add(1, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die1.bmp")
images.Add(2, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die2.bmp")
images.Add(3, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die3.bmp")
images.Add(4, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die4.bmp")
images.Add(5, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die5.bmp")
images.Add(6, "C:\Abhishek\Chegg\VB.net\DiceRolling\DiceRolling\Die6.bmp")
End Sub
End Class
=============form1.designer.vb=========
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.pcbFirstDie = New System.Windows.Forms.PictureBox()
Me.pcbSecondDie = New System.Windows.Forms.PictureBox()
Me.btnRollDice = New System.Windows.Forms.Button()
CType(Me.pcbFirstDie, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.pcbSecondDie, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'pcbFirstDie
'
Me.pcbFirstDie.Location = New System.Drawing.Point(136, 50)
Me.pcbFirstDie.Name = "pcbFirstDie"
Me.pcbFirstDie.Size = New System.Drawing.Size(155, 137)
Me.pcbFirstDie.TabIndex = 0
Me.pcbFirstDie.TabStop = False
'
'pcbSecondDie
'
Me.pcbSecondDie.Location = New System.Drawing.Point(386, 50)
Me.pcbSecondDie.Name = "pcbSecondDie"
Me.pcbSecondDie.Size = New System.Drawing.Size(155, 137)
Me.pcbSecondDie.TabIndex = 1
Me.pcbSecondDie.TabStop = False
'
'btnRollDice
'
Me.btnRollDice.Location = New System.Drawing.Point(253, 287)
Me.btnRollDice.Name = "btnRollDice"
Me.btnRollDice.Size = New System.Drawing.Size(167, 40)
Me.btnRollDice.TabIndex = 2
Me.btnRollDice.Text = "Roll Dice"
Me.btnRollDice.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.btnRollDice)
Me.Controls.Add(Me.pcbSecondDie)
Me.Controls.Add(Me.pcbFirstDie)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.pcbFirstDie, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.pcbSecondDie, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents pcbFirstDie As PictureBox
Friend WithEvents pcbSecondDie As PictureBox
Friend WithEvents btnRollDice As Button
End Class
===========================screen shot of the code===========
Output:
Hi guys! SOS - SOS - SOS Time Sensitive: This assignment is due 11/15/2019 11:59pm I'm...
9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5 Submitting a file upload File Types zip Goals: Write a C++ class with separate.h and.cpp file, use partially filled arrays, Create a new class called Library that uses a private string array to store the list of books The starter code can be downloaded from https://github.com/pisan 342/ass 1-starter (https://github.com/pisan 342/ass 1-starter) You need to submit ass1.zip with the following files in it. Put all...