Make a small program with vb.net (2)

Source: Internet
Author: User
Tags integer
The program uses vb.net to make a small program (2)
----make "Lucky7" program
Author: Alpine

It is a simulation of the lucky Digital coin machine game program. The program's user interface includes two buttons, 3 Lucky number boxes that represent winning digital images and Lucky 7 tags.



Public Class Form1

Inherits System.Windows.Forms.Form



#Region "code generated by the Windows forms Designer"



Public Sub New ()

MyBase.New ()



' This call is required by the Windows Forms Designer.

InitializeComponent ()



' Add any initialization after the InitializeComponent () call



End Sub



' Form overrides disposition to clean up the component list.

Protected Overloads Overrides Sub Dispose (ByVal disposing as Boolean)

If disposing Then

If not (components are nothing) Then

Components. Dispose ()

End If

End If

Mybase.dispose (disposing)

End Sub



' Required by the Windows Forms Designer

Private Components as System.ComponentModel.IContainer



' NOTE: The following procedure is required by the Windows Forms Designer

' You can use the Windows Forms Designer to modify this procedure.

' Do not modify it using the Code Editor.

Friend WithEvents Button1 as System.Windows.Forms.Button

Friend WithEvents Button2 as System.Windows.Forms.Button

Friend WithEvents Label1 as System.Windows.Forms.Label

Friend WithEvents Label2 as System.Windows.Forms.Label

Friend WithEvents Label3 as System.Windows.Forms.Label

Friend WithEvents Label4 as System.Windows.Forms.Label

Friend WithEvents PictureBox1 as System.Windows.Forms.PictureBox

<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()

Dim resources as System.Resources.ResourceManager = New System.Resources.ResourceManager (GetType (FORM1))

Me.button1 = New System.Windows.Forms.Button ()

Me.button2 = New System.Windows.Forms.Button ()

Me.label1 = New System.Windows.Forms.Label ()

Me.label2 = New System.Windows.Forms.Label ()

Me.label3 = New System.Windows.Forms.Label ()

Me.label4 = New System.Windows.Forms.Label ()

Me.picturebox1 = New System.Windows.Forms.PictureBox ()

Me.suspendlayout ()

'

' Button1

'

Me.Button1.Location = New System.Drawing.Point (40, 104)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Spin"

'

' Button2

'

Me.Button2.Location = New System.Drawing.Point (40, 152)

Me.Button2.Name = "Button2"

Me.Button2.TabIndex = 1

Me.Button2.Text = "End"

'

' Label1

'

Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Me.Label1.Font = New System.Drawing.Font ("Official script", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType (134, Byte))

Me.Label1.Location = New System.Drawing.Point (136, 40)

Me.Label1.Name = "Label1"

Me.Label1.TabIndex = 2

Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

'

' Label2

'

Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Me.Label2.Font = New System.Drawing.Font ("Official script", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType (134, Byte))

Me.Label2.Location = New System.Drawing.Point (264, 40)

Me.Label2.Name = "Label2"

Me.Label2.TabIndex = 3

Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

'

' Label3

'

Me.Label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

Me.Label3.Font = New System.Drawing.Font ("Official script", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType (134, Byte))

Me.Label3.Location = New System.Drawing.Point (400, 40)

Me.Label3.Name = "Label3"

Me.Label3.Size = New System.Drawing.Size (100, 24)

Me.Label3.TabIndex = 4

Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

'

' Label4

'

Me.Label4.ForeColor = System.Drawing.Color.Red

Me.Label4.Location = New System.Drawing.Point (24, 200)

Me.Label4.Name = "Label4"

Me.Label4.Size = New System.Drawing.Size (120, 120)

Me.Label4.TabIndex = 5

Me.Label4.Text = "Lucky Seven"

'

' PictureBox1

'

Me.PictureBox1.Image = CType (resources. GetObject ("pictureBox1.Image"), System.Drawing.Bitmap)

Me.PictureBox1.Location = New System.Drawing.Point (208, 120)

Me.PictureBox1.Name = "PictureBox1"

Me.PictureBox1.Size = New System.Drawing.Size (288, 208)

Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage

Me.PictureBox1.TabIndex = 6

Me.PictureBox1.TabStop = False

Me.PictureBox1.Visible = False

'

' Form1

'

Me.autoscalebasesize = New System.Drawing.Size (6, 14)

Me.clientsize = New System.Drawing.Size (528, 350)

Me.Controls.AddRange (New System.Windows.Forms.Control () {me.picturebox1, Me.label4, Me.label3, Me.label2, Me.label1, Me.button2, Me.button1})

Me.Name = "Form1"

Me.Text = "Form1"

Me.resumelayout (False)



End Sub



#End Region



Private Sub Label3_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Label3.click

End Sub



Private Sub button2_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button2.click

End

End Sub



Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click

picturebox1.visible = False ' Hide picture

The ' Rnd function generates a random number between 0 and 1 (with a decimal point and several decimal places), and the INT function multiplies these numbers by 10

' After multiplying by 10 and rounding up an integer, this produces a random integer of 0 to 9.

Label1.Text = CStr (Int (Rnd () * 10)) ' Select number

Label2.Text = CStr (Int (Rnd () * 10))

Label3.text = CStr (Int (Rnd () * 10))

' If a person has a title of 7 then show the picture

If (Label1.Text = "7") or (Label2.Text = "7") or (Label3.text = "7") Then

Picturebox1.visible = True

Beep ()

End If

End Sub

End Class


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.