動作確認済み
Sub BlackJack()
Dim card(52) As Integer
Dim i As Integer
Dim j As Integer
Dim temp As Integer
Dim player(7) As Integer
Dim dealer(7) As Integer
Dim playertotal As Integer
Dim dealertotal As Integer
total = 0
'トランプの生成、1デッキ52枚
For i = 1 To 52
card(i) = i
Next
'混ぜる。最初のカードをtempという箱に待避
For i = 1 To 52
j = Int(Rnd() * 52) + 1
temp = card(i)
card(i) = card(j)
card(j) = temp
Next
'プレイヤーのプレイ
For i = 1 To 2
player(i) = Henkan(i, card(i))
Next
playertotal = player(1) + player(2)
'2枚引いた時点の合計
Cells(3, 1) = "合計は"
Cells(3, 2) = playertotal
'ディーラーの1枚目
'ディーラーの1枚目を見てプレイヤーの判断
'プレイヤーバーストか?
'ディーラーの2枚目以降、16以下は機械的にめくる
'ディーラーバーストか?
'ショーダウン
'結果によるチップの増減
End Sub
'======================================
'連番Cardをマークに付与するプロシージャー(サブルーチン)
'======================================
Function Henkan(order, card)
Select Case card
Case Is <= 13
Cells(order, 1) = "スペードの"
Cells(order, 2) = card
If card > 10 Then
Henkan = 10
Else
Henkan = card
End If
Case Is <= 26
card = card - 13
Cells(order, 1) = "ハートの"
Cells(order, 2) = card
If card > 10 Then
Henkan = 10
Else
Henkan = card
End If
Case Is <= 39
card = card - 26
Cells(order, 1) = "ダイヤの"
Cells(order, 2) = card
If card > 10 Then
Henkan = 10
Else
Henkan = card
End If
Case Else
card = card - 39
Cells(order, 1) = "クローバーの"
Cells(order, 2) = card
If card > 10 Then
Henkan = 10
Else
Henkan = card
End If
End Select
End Function