Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim my_n, nn As Integer Dim rand As New Random For my_i = 1 To 4 my_n = rand.Next(1, 11) Randomize() nn += 1 Select Case nn Case 1 Label1.Text = my_n Case 2 Label2.Text = my_n Case 3 Label3.Text = my_n Case 4 Label4.Text = my_n Case Else End End Select Next End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim my_G1, my_G2 As Integer
If CInt(Label1.Text) = CInt(Label2.Text) Then my_G1 = (CInt(Label1.Text) * 10) + CInt(Label2.Text) Else my_G1 = CInt(Label1.Text) + CInt(Label2.Text) If my_G1 > 10 Then my_G1 = my_G1 - 10 End If End If If CInt(Label3.Text) = CInt(Label4.Text) Then my_G2 = (CInt(Label3.Text) * 10) + CInt(Label4.Text) Else my_G2 = CInt(Label3.Text) + CInt(Label4.Text) If my_G2 > 10 Then my_G2 = my_G2 - 10 End If End If If (CInt(Label1.Text) = 4 And CInt(Label2.Text) = 9) Or (CInt(Label1.Text) = 9 And CInt(Label2.Text) = 4) Or (CInt(Label3.Text) = 4 And CInt(Label4.Text)) = 9 Or (CInt(Label3.Text) = 9 And CInt(Label4.Text)) = 4 Then MsgBox("게임 다시") End If
'승패 결과 If my_G1 > my_G2 Then MsgBox(" 게이머 1 승리") ElseIf my_G1 < my_G2 Then MsgBox(" 게이머 2승리") Else MsgBox(" 비겼습니다 ") End If
Public Class Form1 Dim n(3) As Integer Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Label1.Text = "?" : Label2.Text = "?" : Label3.Text = "?" : Label4.Text = "?" Dim rand As New Random
For i = 0 To 3 n(i) = rand.Next(1, 11) Randomize() Next MsgBox("패를 돌렸습니다") End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = n(0) : Label2.Text = n(1) : Label3.Text = n(2) : Label4.Text = n(3)
If n(0) = n(1) And n(2) = n(3) Then If n(0) > n(2) Then MsgBox("게이머1이 " & n(0) & "땡으로 이겼습니다") ElseIf n(0) < n(2) Then '서로 떙일 경우 MsgBox("게이머2가" & n(2) & "땡으로 이겼습니다") ElseIf n(0) = n(2) Then MsgBox("서로 비겼습니다") End If End If
If n(0) = n(1) And n(2) <> n(3) Then MsgBox("게이머1이 " & n(0) & "땡으로 이겼습니다") ElseIf n(0) <> n(1) And n(2) = n(3) Then '땡,끝 비교 MsgBox("게이머2가 " & n(2) & "땡으로 이겼습니다") End If
If n(0) <> n(1) And n(2) <> n(3) Then '끝 비교 시작
If n(0) + n(1) > 10 And n(2) + n(3) > 10 Then '각 게이머의 패 합계가 10이넘는경우 처리 If ((n(0) + n(1)) - 10) > ((n(2) + n(3)) - 10) Then MsgBox("게이머1이 " & ((n(0) + n(1)) - 10) & "끝 으로 이겼습니다") ElseIf ((n(0) + n(1)) - 10) < ((n(2) + n(3)) - 10) Then MsgBox("게이머2가 " & ((n(2) + n(3)) - 10) & "끝 으로 이겼습니다") ElseIf ((n(0) + n(1)) - 10) = ((n(2) + n(3)) - 10) Then MsgBox("서로 비겼습니다") End If End If
If n(0) + n(1) > 10 And n(2) + n(3) < 11 Then '게이머1의 패 합계가 10넘는경우 처리 If (n(0) + n(1)) - 10 > (n(2) + n(3)) Then MsgBox("게이머1이 " & ((n(0) + n(1)) - 10) & "끝 으로 이겼습니다") Else MsgBox("게이머2가 " & (n(2) + n(3)) & "끝 으로 이겼습니다") End If
ElseIf n(0) + n(1) < 11 And n(2) + n(3) > 10 Then '게이머2의 패 합계가 10넘는경우 처리 If n(0) + n(1) > (n(2) + n(3)) - 10 Then MsgBox("게이머1이 " & (n(0) + n(1)) & "끝 으로 이겼습니다") Else MsgBox("게이머2가 " & ((n(2) + n(3)) - 10) & "끝 으로 이겼습니다") End If End If
If n(0) + n(1) < 11 And n(2) + n(3) < 11 Then '각 게이머의 패 합계가 10보다 작을경우 If n(0) + n(1) > n(2) + n(3) Then MsgBox("게이머1이 " & (n(0) + n(1)) & "끝 으로 이겼습니다") Else MsgBox("게이머2가 " & (n(2) + n(3)) & "끝 으로 이겼습니다") End If
ElseIf n(0) + n(1) = 10 Then '합계 10(망통)이 나왔늘때 처리 MsgBox("게이머2가 " & n(2) + n(3) & "끝 으로 이겼습니다") ElseIf n(2) + n(3) = 10 Then MsgBox("게이머1이 " & n(0) + n(1) & "끝 으로 이겼습니다") ElseIf n(0) + n(1) = 10 And n(2) + n(3) = 10 Then MsgBox("서로 비겼습니다") End If
End If
If (n(0) = 4 And n(1) = 9) Or (n(0) = 9 And n(1) = 4) Then '4,9 패가 나왔을때 처리 MsgBox("게이머1이 4,9가 나와서 이판은 무효입니다") ElseIf (n(2) = 4 And n(3) = 9) Or (n(2) = 9 And n(3) = 4) Then MsgBox("게이머2가 4,9가 나와서 이판은 무효입니다") End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.SetDesktopLocation(500, 500) End Sub End Class
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim my_n, nn As Integer
Dim rand As New Random
For my_i = 1 To 4
my_n = rand.Next(1, 11)
Randomize()
nn += 1
Select Case nn
Case 1
Label1.Text = my_n
Case 2
Label2.Text = my_n
Case 3
Label3.Text = my_n
Case 4
Label4.Text = my_n
Case Else
End
End Select
Next
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim my_G1, my_G2 As Integer
If CInt(Label1.Text) = CInt(Label2.Text) Then
my_G1 = (CInt(Label1.Text) * 10) + CInt(Label2.Text)
Else
my_G1 = CInt(Label1.Text) + CInt(Label2.Text)
If my_G1 > 10 Then
my_G1 = my_G1 - 10
End If
End If
If CInt(Label3.Text) = CInt(Label4.Text) Then
my_G2 = (CInt(Label3.Text) * 10) + CInt(Label4.Text)
Else
my_G2 = CInt(Label3.Text) + CInt(Label4.Text)
If my_G2 > 10 Then
my_G2 = my_G2 - 10
End If
End If
If (CInt(Label1.Text) = 4 And CInt(Label2.Text) = 9) Or (CInt(Label1.Text) = 9 And CInt(Label2.Text) = 4) Or (CInt(Label3.Text) = 4 And CInt(Label4.Text)) = 9 Or (CInt(Label3.Text) = 9 And CInt(Label4.Text)) = 4 Then
MsgBox("게임 다시")
End If
'승패 결과
If my_G1 > my_G2 Then
MsgBox(" 게이머 1 승리")
ElseIf my_G1 < my_G2 Then
MsgBox(" 게이머 2승리")
Else
MsgBox(" 비겼습니다 ")
End If
End Sub
End Class
이 댓글을
Public Class Form1
Dim n(3) As Integer
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Label1.Text = "?" : Label2.Text = "?" : Label3.Text = "?" : Label4.Text = "?"
Dim rand As New Random
For i = 0 To 3
n(i) = rand.Next(1, 11)
Randomize()
Next
MsgBox("패를 돌렸습니다")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = n(0) : Label2.Text = n(1) : Label3.Text = n(2) : Label4.Text = n(3)
If n(0) = n(1) And n(2) = n(3) Then
If n(0) > n(2) Then
MsgBox("게이머1이 " & n(0) & "땡으로 이겼습니다")
ElseIf n(0) < n(2) Then '서로 떙일 경우
MsgBox("게이머2가" & n(2) & "땡으로 이겼습니다")
ElseIf n(0) = n(2) Then
MsgBox("서로 비겼습니다")
End If
End If
If n(0) = n(1) And n(2) <> n(3) Then
MsgBox("게이머1이 " & n(0) & "땡으로 이겼습니다")
ElseIf n(0) <> n(1) And n(2) = n(3) Then '땡,끝 비교
MsgBox("게이머2가 " & n(2) & "땡으로 이겼습니다")
End If
If n(0) <> n(1) And n(2) <> n(3) Then '끝 비교 시작
If n(0) + n(1) > 10 And n(2) + n(3) > 10 Then '각 게이머의 패 합계가 10이넘는경우 처리
If ((n(0) + n(1)) - 10) > ((n(2) + n(3)) - 10) Then
MsgBox("게이머1이 " & ((n(0) + n(1)) - 10) & "끝 으로 이겼습니다")
ElseIf ((n(0) + n(1)) - 10) < ((n(2) + n(3)) - 10) Then
MsgBox("게이머2가 " & ((n(2) + n(3)) - 10) & "끝 으로 이겼습니다")
ElseIf ((n(0) + n(1)) - 10) = ((n(2) + n(3)) - 10) Then
MsgBox("서로 비겼습니다")
End If
End If
If n(0) + n(1) > 10 And n(2) + n(3) < 11 Then '게이머1의 패 합계가 10넘는경우 처리
If (n(0) + n(1)) - 10 > (n(2) + n(3)) Then
MsgBox("게이머1이 " & ((n(0) + n(1)) - 10) & "끝 으로 이겼습니다")
Else
MsgBox("게이머2가 " & (n(2) + n(3)) & "끝 으로 이겼습니다")
End If
ElseIf n(0) + n(1) < 11 And n(2) + n(3) > 10 Then '게이머2의 패 합계가 10넘는경우 처리
If n(0) + n(1) > (n(2) + n(3)) - 10 Then
MsgBox("게이머1이 " & (n(0) + n(1)) & "끝 으로 이겼습니다")
Else
MsgBox("게이머2가 " & ((n(2) + n(3)) - 10) & "끝 으로 이겼습니다")
End If
End If
If n(0) + n(1) < 11 And n(2) + n(3) < 11 Then '각 게이머의 패 합계가 10보다 작을경우
If n(0) + n(1) > n(2) + n(3) Then
MsgBox("게이머1이 " & (n(0) + n(1)) & "끝 으로 이겼습니다")
Else
MsgBox("게이머2가 " & (n(2) + n(3)) & "끝 으로 이겼습니다")
End If
ElseIf n(0) + n(1) = 10 Then '합계 10(망통)이 나왔늘때 처리
MsgBox("게이머2가 " & n(2) + n(3) & "끝 으로 이겼습니다")
ElseIf n(2) + n(3) = 10 Then
MsgBox("게이머1이 " & n(0) + n(1) & "끝 으로 이겼습니다")
ElseIf n(0) + n(1) = 10 And n(2) + n(3) = 10 Then
MsgBox("서로 비겼습니다")
End If
End If
If (n(0) = 4 And n(1) = 9) Or (n(0) = 9 And n(1) = 4) Then '4,9 패가 나왔을때 처리
MsgBox("게이머1이 4,9가 나와서 이판은 무효입니다")
ElseIf (n(2) = 4 And n(3) = 9) Or (n(2) = 9 And n(3) = 4) Then
MsgBox("게이머2가 4,9가 나와서 이판은 무효입니다")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SetDesktopLocation(500, 500)
End Sub
End Class
이 댓글을