Modifikasi Aplikasi “Roulette Table” pada Visual Basic. NET 2010
Setelah sebelumnya sudah saya terapkan pada Visual Basic 6.0 sekarang saya adaptasikan pada Visual Basic.NET. Dalam segi perograman tdak banyak yang berubah tapi dari segi design saya lebih menyukai Visual Basic.NET karena lebih mudah mengatur jarak antar kontrol.
1. Jalankan terlebih dahulu aplikasi Visual Basic 2010
2. Pada tabulasi “Start Page” pilih “New Project” atau bisa juga dengan menekan tombol “Ctrl + N” pada keyboard
3. Pada jendela “New Project” pilih “Windows Forms Application” kemudian tekan tombol “OK”
4. Berikut setingan kontrol properti yang terdapat pada aplikasi ini
Object | Name | Properties | Setting |
Form | Form1 | Font | Tahoma; 10pt |
Form Border Style | Fixed Single | ||
Maximize Box | False | ||
Minimize Box | False | ||
Start Position | Center Screen | ||
Text | Roulette Table | ||
Label | lblDisplay1 | Auto Size | False |
Back Color | White | ||
Font | Tahoma; 28pt | ||
Text | (Empty) | ||
Text Align | Middle Center | ||
Label | lblDisplay2 | Auto Size | False |
Back Color | White | ||
Font | Tahoma; 28pt | ||
Text | (Empty) | ||
Text Align | Middle Center | ||
Label | lblDisplay3 | Auto Size | False |
Back Color | White | ||
Font | Tahoma; 28pt | ||
Text | (Empty) | ||
Text Align | Middle Center | ||
Picture Box | picDisplay | Image | C:\Program Files\Microsoft Visual Studio\Common\Graphics\Metafile\Business\MONEY.WMF |
Size Mode | Stretch Image | ||
Visible | False | ||
Button | cmdSpin | Text | Spin |
Button | cmdExit | Text | E&xit |
Label | lblDisplayPlayed | Font | Tahoma; 12pt |
Text | Played: | ||
Label | lblPlayed | Auto Size | False |
Back Color | White | ||
Border Style | Fixed 3D | ||
Font | Tahoma; 12pt | ||
Text | 0 | ||
Text Align | Middle Center | ||
Label | lblDisplayPoint | Font | Tahoma; 12pt |
Text | Point: | ||
Label | lblPoint | Auto Size | False |
Back Color | White | ||
Border Style | Fixed 3D | ||
Font | Tahoma; 12pt | ||
Text | 1000 | ||
Text Align | Middle Center | ||
Label | lblDisplayWin | Font | Tahoma; 12pt |
Text | Win: | ||
Label | lblWinCount | Auto Size | False |
Back Color | White | ||
Border Style | Fixed 3D | ||
Font | Tahoma; 12pt | ||
Text | 0 | ||
Text Align | Middle Center | ||
Label | lblDisplayLose | Font | Tahoma; 12pt |
Text | Lose: | ||
Label | lblLoseCount | Auto Size | False |
Back Color | White | ||
Border Style | Fixed 3D | ||
Font | Tahoma; 12pt | ||
Text | 0 | ||
Text Align | Middle Center | ||
Label | lblDisplayBets | Font | Tahoma; 12pt |
Text | Total Bets: | ||
Label | lblBets | Auto Size | False |
Back Color | White | ||
Border Style | Fixed 3D | ||
Font | Tahoma; 12pt | ||
Text | 0 | ||
Text Align | Middle Center |
5. Berikut event code program
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
End Sub
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
End
End Sub
Private Sub cmdSpin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSpin.Click
Dim Count, Response, Bets As Integer
picDisplay.Visible = False
lblDisplay1.Text = Int(Rnd() * 10)
lblDisplay2.Text = Int(Rnd() * 10)
lblDisplay3.Text = Int(Rnd() * 10)
Count = 0
Count = lblPlayed.Text
lblPlayed.Text = Val(Count) + 1
If lblDisplay1.Text = 9 Or lblDisplay2.Text = 9 Or lblDisplay3.Text = 9 Then
picDisplay.Visible = True
lblPoint.Text = Val(lblPoint.Text) + 100
lblWinCount.Text = Val(lblWinCount.Text) + 1
Else
lblPoint.Text = Val(lblPoint.Text) - 100
lblLoseCount.Text = Val(lblLoseCount.Text) + 1
End If
If lblDisplay1.Text = 9 And lblDisplay2.Text = 9 Then
lblPoint.Text = Val(lblPoint.Text) + 100
ElseIf lblDisplay1.Text = 9 And lblDisplay3.Text = 9 Then
lblPoint.Text = Val(lblPoint.Text) + 100
ElseIf lblDisplay2.Text = 9 And lblDisplay3.Text = 9 Then
lblPoint.Text = Val(lblPoint.Text) + 100
End If
If lblDisplay1.Text = 9 And lblDisplay2.Text = 9 And lblDisplay3.Text = 9 Then
lblPoint.Text = Val(lblPoint.Text) + 200
End If
If lblPoint.Text = "0" Then
Response = MsgBox("You don’t have enough point!!" + vbCrLf + vbCrLf + "Try again?", vbQuestion + vbYesNo, "Confirmation")
If Response = vbYes Then
lblPoint.Text = 1000
lblWinCount.Text = 0
lblLoseCount.Text = 0
lblPlayed.Text = 0
lblDisplay1.Text = 0
lblDisplay2.Text = 0
lblDisplay3.Text = 0
Bets = 1000
lblBets.Text = Bets + Val(lblBets.Text)
Else
End
End If
End If
End Sub
End Class
Label: VB.NET
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda