?? form1.frm
字號:
VERSION 5.00
Begin VB.Form frmCard
Caption = "Card Shuffling and Dealing Simuation"
ClientHeight = 3075
ClientLeft = 60
ClientTop = 345
ClientWidth = 4695
LinkTopic = "Form1"
ScaleHeight = 3075
ScaleWidth = 4695
StartUpPosition = 3 'Windows Default
Begin VB.ListBox lstOutput
Height = 2595
Left = 0
TabIndex = 1
Top = 480
Width = 4695
End
Begin VB.CommandButton cmdShuffle
Caption = "Shuffle and Deal Cards"
Height = 375
Left = 0
TabIndex = 0
Top = 0
Width = 4695
End
End
Attribute VB_Name = "frmCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 8.31
' A card shuffling and dealing simulation
Option Explicit
Dim mSuit(1 To 4) As String, mFace(1 To 13) As String
Dim mDeck(1 To 4, 1 To 13) As Integer
Private Sub Form_Load()
mSuit(1) = "Hearts"
mSuit(2) = "Diamonds"
mSuit(3) = "Clubs"
mSuit(4) = "Spades"
mFace(1) = "Ace"
mFace(2) = "Deuce"
mFace(3) = "Three"
mFace(4) = "Four"
mFace(5) = "Five"
mFace(6) = "Six"
mFace(7) = "Seven"
mFace(8) = "Eight"
mFace(9) = "Nine"
mFace(10) = "Ten"
mFace(11) = "Jack"
mFace(12) = "Queen"
mFace(13) = "King"
Call Randomize
End Sub
Private Sub cmdShuffle_Click()
Call lstOutput.Clear
Call Shuffle
Call Deal
End Sub
Private Sub Shuffle()
Dim card As Integer, row As Integer, column As Integer
Call ZeroDeckArray
For card = 1 To 52
Do
row = 1 + Int(Rnd() * UBound(mSuit))
column = 1 + Int(Rnd() * UBound(mFace))
Loop While mDeck(row, column) <> 0
mDeck(row, column) = card
Next
End Sub
Private Sub Deal()
Dim card As Integer, row As Integer, column As Integer
For card = 1 To 52
For row = LBound(mSuit) To UBound(mSuit)
For column = LBound(mFace) To UBound(mFace)
If mDeck(row, column) = card Then
lstOutput.AddItem ( _
mFace(column) & " of " & mSuit(row))
End If
Next column
Next row
Next card
End Sub
Private Sub ZeroDeckArray()
Dim row As Integer, column As Integer
For row = LBound(mSuit) To UBound(mSuit)
For column = LBound(mFace) To UBound(mFace)
mDeck(row, column) = 0
Next column
Next row
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -