四人发牌游戏,显示时10显示不出,顺便问问这个程序还能简化并美化界面!
Public Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(51) As String
Dim i As Integer
Dim s As String
Dim s1 As String
Dim s2 As String
Dim s3 As String
s = ""
s1 = ""
s2 = ""
s3 = ""
Dim pai(12) As Char
pai(0) = "K"
pai(1) = "A"
pai(2) = "2"
pai(3) = "3"
pai(4) = "4"
pai(5) = "5"
pai(6) = "6"
pai(7) = "7"
pai(8) = "8"
pai(9) = "9"
pai(10) = "10"
pai(11) = "J"
pai(12) = "Q"
Dim hua(3) As String
hua(0) = "红桃" '红桃
hua(1) = "方片" '方片
hua(2) = "梅花" '梅花
hua(3) = "黑桃" '黑桃
'For i = 0 To 12 '构造每种花色的13张扑克牌
' pai(i) = i
'Next
For i = 0 To 51
A: a(i) = hua(Int(Rnd() * 4)) & pai(Int(Rnd() * 13)) '从第一张开始逐张取抽扑克牌
For j = 0 To i - 1 '从已抽取的扑克牌中查找是否有重复
If a(i) = a(j) Then
GoTo A '如果有则重新抽牌
End If
Next
Next
For i = 0 To 51
If i < 13 And i >= 0 Then
s = s & " " & a(i)
TextBox1.Text = s
ElseIf i < 26 And i >= 13 Then
s1 = s1 & " " & a(i)
TextBox2.Text = s1
ElseIf i < 39 And i >= 26 Then
s2 = s2 & " " & a(i)
TextBox3.Text = s2
ElseIf i < 52 And i >= 39 Then
s3 = s3 & " " & a(i)
TextBox4.Text = s3
End If
Next
's = ""
'For i = 0 To 51 Step 1
' If i < 13 And i >= 0 Then
' s = s & " " & a(i)
' TextBox1.Text = s
' End If
'Next
's = ""
'For i = 0 To 51 Step 1
' If i < 26 And i >= 13 Then
's1 = s1 & " " & a(i)
'TextBox2.Text = s
' End If
'Next
's = ""
'For i = 0 To 51 Step 1
' If i < 39 And i >= 26 Then
' s = s & " " & a(i)
' TextBox3.Text = s
' End If
'Next
's = ""
'For i = 0 To 51 Step 1
' If i < 52 And i >= 39 Then
' s = s & " " & a(i)
' TextBox4.Text = s
' End If
'Next
End Sub
End Class
--------------------编程问答-------------------- Dim pai(12) As Char
pai(10) = "10"
char类型的只能放一个字符,"10"是两个字符。
--------------------编程问答-------------------- Dim pai(12) As Char
改成
Dim pai(12) As string
--------------------编程问答-------------------- 已经改成object啦,谢了啊 --------------------编程问答-------------------- 其实 你使用 16进制 不是更好
只在最后 显示的部分 进行 判断输出
补充:.NET技术 , VB.NET