Excel に付属する Visual Basic Editer
6日目
トランプゲームを作る
�� バカラ
ゲーム説明 ルール
簡単なプログラムを作れるように解説します
ここではミニプログラムの作成過程を体験してください。
はじめに
� /�字のみの表示で作る
�◆.�ード図を読み込み表示する
�� 音楽を入れる
�� カードの絵を取り込む2

image20に裏面を、image21を作る
次の幼にプログラムを修正する。【赤色】
Dim a, b, c, d, e, f, x, y, kane, kake, flag, aa, bb, cc, dd, ee, ff, g
Private Sub cardhai()
If g = 1 Then Image21.Picture = Image7.Picture
If g = 2 Then Image21.Picture = Image8.Picture
If g = 3 Then Image21.Picture = Image9.Picture
If g = 4 Then Image21.Picture = Image10.Picture
If g = 5 Then Image21.Picture = Image11.Picture
If g = 6 Then Image21.Picture = Image12.Picture
If g = 7 Then Image21.Picture = Image13.Picture
If g = 8 Then Image21.Picture = Image14.Picture
If g = 9 Then Image21.Picture = Image15.Picture
If g = 10 Then Image21.Picture = Image16.Picture
If g = 11 Then Image21.Picture = Image17.Picture
If g = 12 Then Image21.Picture = Image18.Picture
If g = 13 Then Image21.Picture = Image19.Picture
End Sub
Private Sub CommandButton1_Click()
kane = 1000
kake = 100
TextBox8 = kane
TextBox9 = kake
End Sub
Private Sub CommandButton2_Click()
Image1.Picture = Image20.Picture
Image2.Picture = Image20.Picture
Image3.Picture = Image20.Picture
Image4.Picture = Image20.Picture
Image5.Picture = Image20.Picture
Image6.Picture = Image20.Picture
a = Int(Rnd() * 13 + 1)
b = Int(Rnd() * 13 + 1)
c = Int(Rnd() * 13 + 1)
d = Int(Rnd() * 13 + 1)
e = Int(Rnd() * 13 + 1)
f = Int(Rnd() * 13 + 1)
aa = a
bb = b
cc = c
dd = d
ee = e
ff = f
If a > 9 Then aa = 0
If b > 9 Then bb = 0
If c > 9 Then cc = 0
If d > 9 Then dd = 0
If e > 9 Then ee = 0
If f > 9 Then ff = 0
x = 0
y = 0
TextBox1 = a
g = a
Call cardhai
Image1.Picture = Image21.Picture
TextBox2 = b
g = b
Call cardhai
Image2.Picture = Image21.Picture
TextBox3 = "???"
TextBox4 = "???"
TextBox5 = e
g = e
Call cardhai
Image5.Picture = Image21.Picture
TextBox6 = "???"
flag = 1
kake = TextBox9
End Sub
Private Sub CommandButton3_Click()
If flag = 1 Then
TextBox1 = a
g = a
Call cardhai
Image1.Picture = Image21.Picture
TextBox2 = b
g = b
Call cardhai
Image2.Picture = Image21.Picture
TextBox3 = "NO"
TextBox4 = d
g = d
Call cardhai
Image4.Picture = Image21.Picture
TextBox5 = e
g = e
Call cardhai
Image5.Picture = Image21.Picture
x = aa + bb
y = dd + ee
If x > 9 Then x = x - 10
If y > 9 Then y = y - 10
If y < 6 Then
TextBox6 = f
g = f
Call cardhai
Image6.Picture = Image21.Picture
y = y + ff
If y > 9 Then y = y - 10
End If
If x > y Then
TextBox7 = "あなたの勝ち"
kane = kane + kake
End If
If x < y Then
TextBox7 = "あなたの負け"
kane = kane - kake
End If
If x = y Then TextBox7 = "引き分け"
TextBox8 = kane
TextBox9 = kake
flag = 0
End If
End Sub
Private Sub CommandButton4_Click()
If flag = 1 Then
TextBox1 = a
g = a
Call cardhai
Image1.Picture = Image21.Picture
TextBox2 = b
g = b
Call cardhai
Image2.Picture = Image21.Picture
TextBox3 = c
g = c
Call cardhai
Image3.Picture = Image21.Picture
TextBox4 = d
g = d
Call cardhai
Image4.Picture = Image21.Picture
TextBox5 = e
g = e
Call cardhai
Image5.Picture = Image21.Picture
x = aa + bb + cc
y = dd + ee
If x > 9 Then x = x - 10
If x > 9 Then x = x - 10
If y > 9 Then y = y - 10
If y < 6 Then
TextBox6 = f
g = f
Call cardhai
Image6.Picture = Image21.Picture
y = y + ff
If y > 9 Then y = y - 10
End If
If x > y Then
TextBox7 = "あなたの勝ち"
kane = kane + kake
End If
If x < y Then
TextBox7 = "あなたの負け"
kane = kane - kake
End If
If x = y Then TextBox7 = "引き分け"
TextBox8 = kane
TextBox9 = kake
flag = 0
End If
End Sub

