LABEL 속성을 활용한 주사위 굴리기 프로그램
*
Public Class Form1
Dim rand As New Random
Dim t As Integer
Dim image1 As Image
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim xx As Integer

Randomize()
xx = rand.Next(1, 7)

Select Case xx
Case 1
image1 = Image.FromFile(Application.StartupPath + "\image\1.jpg")
Case 2
image1 = Image.FromFile(Application.StartupPath + "\image\2.jpg")
Case 3
image1 = Image.FromFile(Application.StartupPath + "\image\3.jpg")
Case 4
image1 = Image.FromFile(Application.StartupPath + "\image\4.jpg")
Case 5
image1 = Image.FromFile(Application.StartupPath + "\image\5.jpg")
Case 6
image1 = Image.FromFile(Application.StartupPath + "\image\6.jpg")
End Select

Label1.Image = image1
t -= 1
If t = 15 Then
Timer1.Interval = 100
ElseIf t = 13 Then
Timer1.Interval = 300
ElseIf t = 10 Then
Timer1.Interval = 500
ElseIf t = 3 Then
Timer1.Interval = 600
ElseIf t = 0 Then
Timer1.Stop()
Label2.Visible = True
End If
Label2.Text = xx & " 이(가) 나왔네요!!"
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Label1.Text = ""
Timer1.Start()
t = 30
Label2.Text = "" : Label2.Visible = False
Timer1.Interval = 50
End Sub

End Class

AA.png

LABEL 속성, TIMER, 난수발생을 이용하여 주사위 굴리는 프로그램 입니다

난수 발생(1-6) 결과에 따라 해당 그림을 라벨배경으로 깔아줍니다

이 게시물을

댓글'1'

Timer안에 Beep()를 넣어주면 효과음이 납니다

이 댓글을

공유하기

SEARCH

MENU NAVIGATION