自动发牌的vb程序

基本要求程序模拟扑克牌的洗牌、发牌过程。通过相应的命令按钮,在新弹出的窗口中显示每人手中持有的扑克牌。问题描述一副扑克有52张牌,打桥牌时应将牌分给四个人。请设计一个程序... 基本要求
程序模拟扑克牌的洗牌、发牌过程。通过相应的命令按钮,在新弹出的窗口中显示每人手中持有的扑克牌。

问题描述
一副扑克有52张牌,打桥牌时应将牌分给四个人。请设计一个程序完成自动发牌的工作。要求:黑桃用S (Spaces)表示;红桃用H (Hearts)表示;方块用D (Diamonds)表示;梅花用C(Clubs)表示。按照打桥牌的规定,每人应当有13张牌。在人工发牌时,先进行“洗牌”,然后将洗好的牌按一定的顺序发给每一个人。为了便于计算机模拟,可将人工方式的发牌过程加以修改:先确定好发牌顺序:西、北、东、南;将52张牌按花色顺序编号:如黑桃用S1-S13表示;红桃用H1-H13表示;红桃用H1-H13表示;红桃用H1-H13表示;然后从52张牌中随机的为每个人抽牌。
点击发牌按钮后,再点击西、北、东、南按钮弹出新的一个窗口显示手中的13张牌。
在“发牌”按钮完成洗牌——产生一个随机序列,对随机序列排序,完成洗牌;发牌——把52数组元素的值(52张牌)分别赋值给代表西、北、东、南四方的数组。西、北、东、南按钮弹出新窗口,用Image控件数组显示13张扑克牌。13个Image控件数组元素上下叠放,鼠标点中的图片通过Zorder方法把图片提前显示。在每个新弹出窗口的Load事件里加载Image控件数组元素,在Activate事件里加载图片。
展开
 我来答
方成虎
2012-06-27
知道答主
回答量:57
采纳率:0%
帮助的人:14.8万
展开全部
Dim Cards(1 To 52) As StringDim seq(1 To 52) As IntegerDim W(1 To 13) As IntegerDim N(1 To 13) As IntegerDim E(1 To 13) As IntegerDim S(1 To 13) As IntegerDim t As Integer
Private Sub Command1_Click()For i = 1 To 13For j = i + 1 To 13 If N(i) > N(j) Then t = N(i) N(i) = N(j) N(j) = t End If Next j Next i
Form3.Image1.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(1)) & ".GIF")Form3.Image2.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(2)) & ".GIF")Form3.Image3.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(3)) & ".GIF")Form3.Image4.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(4)) & ".GIF")Form3.Image5.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(5)) & ".GIF")Form3.Image6.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(6)) & ".GIF")Form3.Image7.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(7)) & ".GIF")Form3.Image8.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(8)) & ".GIF")Form3.Image9.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(9)) & ".GIF")Form3.Image10.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(10)) & ".GIF")Form3.Image11.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(11)) & ".GIF")Form3.Image12.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(12)) & ".GIF")Form3.Image13.Picture = LoadPicture(App.Path & "\GIF\" & Cards(N(13)) & ".GIF")Form3.ShowEnd Sub
Private Sub Command2_Click()For i = 1 To 13For j = i + 1 To 13 If S(i) > S(j) Then t = S(i) S(i) = S(j) S(j) = t End If Next j Next i
Form5.Image1.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(1)) & ".GIF")Form5.Image2.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(2)) & ".GIF")Form5.Image3.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(3)) & ".GIF")Form5.Image4.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(4)) & ".GIF")Form5.Image5.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(5)) & ".GIF")Form5.Image6.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(6)) & ".GIF")Form5.Image7.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(7)) & ".GIF")Form5.Image8.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(8)) & ".GIF")Form5.Image9.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(9)) & ".GIF")Form5.Image10.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(10)) & ".GIF")Form5.Image11.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(11)) & ".GIF")Form5.Image12.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(12)) & ".GIF")Form5.Image13.Picture = LoadPicture(App.Path & "\GIF\" & Cards(S(13)) & ".GIF")Form5.ShowEnd Sub
Private Sub Command3_Click()For i = 1 To 13For j = i + 1 To 13 If W(i) > W(j) Then t = W(i) W(i) = W(j) W(j) = t End If Next j Next i
Form2.Image1.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(1)) & ".GIF")Form2.Image2.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(2)) & ".GIF")Form2.Image3.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(3)) & ".GIF")Form2.Image4.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(4)) & ".GIF")Form2.Image5.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(5)) & ".GIF")Form2.Image6.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(6)) & ".GIF")Form2.Image7.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(7)) & ".GIF")Form2.Image8.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(8)) & ".GIF")Form2.Image9.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(9)) & ".GIF")Form2.Image10.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(10)) & ".GIF")Form2.Image11.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(11)) & ".GIF")Form2.Image12.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(12)) & ".GIF")Form2.Image13.Picture = LoadPicture(App.Path & "\GIF\" & Cards(W(13)) & ".GIF")Form2.ShowEnd Sub
Private Sub Command4_Click()For i = 1 To 13For j = i + 1 To 13 If E(i) > E(j) Then t = E(i) E(i) = E(j) E(j) = t End If Next j Next i
Form4.Image1.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(1)) & ".GIF")Form4.Image2.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(2)) & ".GIF")Form4.Image3.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(3)) & ".GIF")Form4.Image4.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(4)) & ".GIF")Form4.Image5.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(5)) & ".GIF")Form4.Image6.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(6)) & ".GIF")Form4.Image7.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(7)) & ".GIF")Form4.Image8.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(8)) & ".GIF")Form4.Image9.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(9)) & ".GIF")Form4.Image10.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(10)) & ".GIF")Form4.Image11.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(11)) & ".GIF")Form4.Image12.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(12)) & ".GIF")Form4.Image13.Picture = LoadPicture(App.Path & "\GIF\" & Cards(E(13)) & ".GIF")Form4.ShowEnd Sub
Private Sub Command5_Click()Dim ABC(1 To 52) As IntegerABC(1) = Int(52 * Rnd() + 1)seq(1) = ABC(1)For i = 2 To 52ll: ABC(i) = Int(52 * Rnd() + 1) For j = 1 To i - 1 If ABC(i) = ABC(j) Then GoTo ll Next seq(i) = ABC(i)NextFor i = 1 To 13W(i) = seq(i)N(i) = seq(i + 13)E(i) = seq(i + 26)S(i) = seq(i + 39)Next iMsgBox "发牌完成。", vbOKOnly, "好了"Command1.Enabled = TrueCommand2.Enabled = TrueCommand3.Enabled = TrueCommand4.Enabled = TrueEnd Sub
Private Sub Command6_Click()EndEnd Sub
Private Sub Form_Load()Cards(1) = "S1"Cards(2) = "S2"Cards(3) = "S3"Cards(4) = "S4"Cards(5) = "S5"Cards(6) = "S6"Cards(7) = "S7"Cards(8) = "S8"Cards(9) = "S9"Cards(10) = "S10"Cards(11) = "S11"Cards(12) = "S12"Cards(13) = "S13"Cards(14) = "H1"Cards(15) = "H2"Cards(16) = "H3"Cards(17) = "H4"Cards(18) = "H5"Cards(19) = "H6"Cards(20) = "H7"Cards(21) = "H8"Cards(22) = "H9"Cards(23) = "H10"Cards(24) = "H11"Cards(25) = "H12"Cards(26) = "H13"Cards(27) = "D1"Cards(28) = "D2"Cards(29) = "D3"Cards(30) = "D4"Cards(31) = "D5"Cards(32) = "D6"Cards(33) = "D7"Cards(34) = "D8"Cards(35) = "D9"Cards(36) = "D10"Cards(37) = "D11"Cards(38) = "D12"Cards(39) = "D13"Cards(40) = "C1"Cards(41) = "C2"Cards(42) = "C3"Cards(43) = "C4"Cards(44) = "C5"Cards(45) = "C6"Cards(46) = "C7"Cards(47) = "C8"Cards(48) = "C9"Cards(49) = "C10"Cards(50) = "C11"Cards(51) = "C12"Cards(52) = "C13"End Sub
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
擦取名真难擦
2012-06-19
知道答主
回答量:53
采纳率:0%
帮助的人:16万
展开全部
10分 就想弄个程序 哈哈
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友c2521c9
2012-06-23 · 超过28用户采纳过TA的回答
知道答主
回答量:207
采纳率:0%
帮助的人:86.6万
展开全部
单做可以.QQ:497629458
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
hbiccyu
2012-06-24 · TA获得超过195个赞
知道小有建树答主
回答量:310
采纳率:0%
帮助的人:204万
展开全部
程序太好做了!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式