用VB写一个和电脑猜石头剪刀布的小游戏(要代码)

\u5e2e\u5fd9\u7528vb\u8bed\u8a00\u7f16\u4e00\u4e2a\u4e0e\u7535\u8111\u73a9\u526a\u5200\u77f3\u5934\u5e03\u6e38\u620f\uff0c

VB\u505a\u63a7\u5236\u53f0\u7a0b\u5e8f\u6bd4\u8f83\u96be,\u4f60\u8fd8\u662f\u7528\u7a97\u53e3\u5427.
\u63a7\u5236\u53f0\u7a0b\u5e8f\u76f4\u63a5\u7528BAT\u5c31\u884c\u4e86,\u7528\u8bb0\u4e8b\u672c\u5b58\u6210bat\u6587\u4ef6.

::SSC\u7248\u672c\uff1a0.1.0.0
::2010\u5e749\u67085\u65e5

@echo off
color f0
Setlocal enabledelayedexpansion

:Start
Set NoMax=32767
Set /a No.1=%NoMax% / 3
Goto Main

:EchoM
Cls
Echo ------------------
Echo.
Echo 1.\u77f3\u5934
Echo.
Echo 2.\u526a\u5200
Echo.
Echo 3.\u5e03
Echo.
Echo ------------------
Goto :eof

:EchoR
Cls
IF /i "%1"=="Win" ( Echo You Win )
If /i "%1"=="Lost" ( echo You Lost )
If /i "%1"=="Tp" ( Echo \u53cc\u65b9\u5e73\u624b )
Set /p=\u7535\u8111\u51fa\u7684\u662f<nul
If "%2"=="1" Echo \u77f3\u5934
If "%2"=="2" Echo \u526a\u5200
If "%2"=="3" Echo \u5e03
Set /p=\u4f60\u51fa\u7684\u662f<nul
If "%3"=="1" Echo \u77f3\u5934
If "%3"=="2" Echo \u526a\u5200
If "%3"=="3" Echo \u5e03
Goto :eof


:Main
Call :EchoM
Set App=~
Set /p App=\u8bf7\u8f93\u5165\uff1a
If "%APP%"=="1" Goto ex
If "%APP%"=="2" Goto ex
If "%APP%"=="3" Goto ex
Echo \u8f93\u5165\u9519\u8bef\uff01
ping /n 2 127.1>nul
Goto Main

:EX
Set /a No.3=%RANDOM% / %No.1% + 1
IF %App% EQU %No.3% (
Call :echor tp %No.3% %App%
) else (
IF %App%==1 ( If %no.3%==3 Set app=4 )
If %no.3%==1 ( If %App%==3 Set no.3=4)
If !app! GTR !No.3! call :echor lost %No.3% %App%
IF !No.3! GTR !app! call :echor win %No.3% %App%
)

Pause>NUL
Goto Main

\u5728\u4ee3\u7801\u9875\u7684\u6700\u524d\u9762\u52a0\u5165\u4ee5\u4e0b\u76842\u884c\uff1a
Option Base 1
Dim x As Integer, y As Integer, z As Integer

\u53e6\u5916\uff0c\u6240\u6709\u7684\u4ee5\u4e0b\u90e8\u5206\u8981\u4fee\u6539\uff1a
Text1.Text = ("\u7535\u8111\u80dc\u5229 ") & x&(" \u76d8")
Text2.Text = ("\u4f60\u80dc\u5229 ") & y&(" \u76d8")
\u6539\u4e3a\uff1a
Text1.Text = "\u7535\u8111\u80dc\u5229 " & x & " \u76d8"
Text2.Text = "\u4f60\u80dc\u5229 " & y & " \u76d8"

如你所说
1、建立三个按钮command1,command2,command3
2、建立两个标签label1,label2
3、复制代码,运行
Dim a As Long
Dim b As Long
Dim c As Long
Dim e As Long

Private Sub Command1_Click()
c = 1
Call check(c)
End Sub

Private Sub Command2_Click()
c = 2
Call check(c)
End Sub

Private Sub Command3_Click()
c = 3
Call check(c)
End Sub

Private Sub Form_Load()
Command1.Caption = "石头"
Command2.Caption = "剪刀"
Command3.Caption = "布"
Label1.Caption = ""
a = 0
b = 0
e = 0
Call printt(a, b, e, 0)
End Sub
Sub check(temp As Long)
Dim d As Long
Randomize
d = Int(Rnd * 3 + 1)
If d = temp Then
e = e + 1
Call printt(a, b, e, d)
Else
Select Case d
Case 1
If temp = 2 Then
a = a + 1
Call printt(a, b, e, d)
ElseIf temp = 3 Then
b = b + 1
Call printt(a, b, e, d)
End If
Case 2
If temp = 1 Then
b = b + 1
Call printt(a, b, e, d)
ElseIf temp = 3 Then
a = a + 1
Call printt(a, b, e, d)
End If
Case 3
If temp = 1 Then
a = a + 1
Call printt(a, b, e, d)
ElseIf temp = 2 Then
b = b + 1
Call printt(a, b, e, d)
End If
End Select
End If
End Sub
Sub printt(temp1 As Long, temp2 As Long, temp3 As Long, temp4 As Long)
Label2.Caption = "电脑赢" & temp1 & "次," & "你赢" & temp2 & "次," & "平局" & temp3 & "次。"
Select Case temp4
Case 1
Label1.Caption = "石头"
Case 2
Label1.Caption = "剪刀"
Case 3
Label1.Caption = "布"
Case 0
Label1.Caption = "电脑还未出"
End Select
End Sub

试密码的程序:
sub form1_load()
dim i as long
for i=0 to 2147483647
print i
next i
end sub

  • vb鎬庝箞鍒朵綔鍓垁鐭冲ご甯娓告垙,鎸夐挳瑕佹湁涓嬫媺鑿滃崟鐨勫拰鐐瑰嚮鎸夐挳鍙繘鍏ユ父鎴忚鏄...
    绛旓細+ 1) '浜х敓涓涓1~3鐨勯殢鏈烘暟 Select Case computer Case 1 Picture1.Picture = LoadPicture(App.Path & "\10.jpg") '鐢佃剳鍑鐭冲ご Case 2 Picture1.Picture = LoadPicture(App.Path & "\20.jpg") '鐢佃剳鍑鍓垁 Case 3 Picture1.Picture = LoadPicture(App.Path & "...
  • VB涓鐭冲ご鍓垁甯娓告垙鐨勭▼搴忎唬鐮佽鍏ㄥ摝
    绛旓細Private Sub Command1_Click()Randomize x = "鈼徝椻枴"a = Mid(x, Int(Rnd() * 3 + 1), 1)b = Mid(x, Int(Rnd() * 3 + 1), 1)If a = "鈼" And b = "脳" Then c = "A鑳"If a = "鈼" And b = "鈻" Then c = "B鑳"If a = "脳" And b = "鈻" Then ...
  • VB灏忔父鎴鐭冲ご鍓垁甯璁剧疆浠g爜
    绛旓細option.value=true 琛ㄧず琚変腑鐨勬剰鎬 褰撲綘瑙﹀彂option1 click浜嬩欢鍚 濡傛灉涓嶈缃寜閽笉鍙敤 閭d箞鍦ㄦ帴涓嬫潵鍑哄彂鍒殑鎸夐挳鐨刢lick浜嬩欢鍚庯紝灏变細浜х敓涓や釜鎸夐挳閮借閫変腑锛屼粠鑰屽鑷存姤閿
  • 瑙i噴涓涓嬭繖vb涓浠g爜銆傘傘傜湅涓嶆噦銆傘傘
    绛旓細浠庣▼搴忕湅YOU(1)=1 琛ㄧず鐭冲ご YOU(2)=2 琛ㄧず鍓垁 YOU(3)=3 琛ㄧず甯 濡傚綋浣犳寜涓媃OU(1)杩欎釜鎺у埗锛岃〃绀轰綘鍑虹殑鏄煶澶达紝涔熷氨鏄痯rivate sub YOU_click(index as long)INDEX=1 A2 = Fix(Rnd * 3 + 1) '鐢鐢佃剳闅忔満寰楀埌鏁板瓧1鎴2鎴3 A2鐢辩數鑴戦殢鏃跺緱鍒扮殑銆傚拰浣犲嚭鐨凙1鐩告瘮杈 ...
  • 缂栧啓涓涓绋嬪簭,璁璁$畻鏈鍚屾垜浠竴璧风帺鍓垁鐭冲ご甯銆傚鏋滀汉杈撲簡,鍒欒緭鍑衡渓...
    绛旓細Label1.Caption = "LOSE"ElseIf computer = 3 Then Label1.Caption = "DEUCE"End If End Sub Private Sub text()Command1.Caption = "鐭冲ご"Command2.Caption = "鍓垁"Command3.Caption = "甯"Label1.Caption = "鐚滄嫵"End Sub Private Sub Label2_Click()End Sub 绗簩涓 Private Sub ...
  • 鏈夋病鏈夌幇鎴愮殑鎴栬呭仛濂界殑鍜岀數鑴戝壀鍒鐭冲ご甯鐨勮蒋浠,鑳界敤VS2012閲岀殑VB鎵撳紑鐨...
    绛旓細import java.util.Random;import javax.swing.*;import java.awt.BorderLayout;import java.awt.Container;import java.awt.event.*;public class SmallGame extends JFrame { private Random r;private final String[] box = {"鍓垁","鐭冲ご","甯"};private JComboBox choice;private JTextArea ta;...
  • 鎬庝箞鐢╒B缂涓涓鐚滄嫵娓告垙?
    绛旓細Randomize Timer computer = Int(Rnd * 3 + 1)If computer = 1 Then Label3.Caption = "鍓垁"If computer = 2 Then Label3.Caption = "鐭冲ご"If computer = 3 Then Label3.Caption = "甯"a = user - computer If a = 0 Then Print "骞"If a = -1 Or a = 2 Then Print "杈"...
  • 鏈vb澶х,缁欏嚭杩欓亾棰樼殑瀹為獙姝ラ(鍖呮嫭娴佺▼鍥,璁捐鎬濇兂涓庡疄鐜版楠)
    绛旓細GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Sub Command1_Click() Dim s(3) s(1) = "鐭冲ご" s(2) = "鍓垁" s(3) = "甯" For i = 0 To Option1.UBound If Option1(i).Value Then...
  • vb灏忕▼搴忚璁
    绛旓細涓嶈兘鏈夐敊 娉ㄦ剰宸﹁竟妗嗘灦閲岄潰杩樻湁涓涓鏍囩 涓嶈蹇樿!!Private Sub Command1_Click()Randomize Dim a%, b%, c%, cr cr = Int(3 * Rnd + 1)If cr = 1 Then Label1.Caption = "鐭冲ご"ElseIf cr = 2 Then Label1.Caption = "鍓垁"ElseIf cr = 3 Then Label1.Caption = "甯"End If...
  • VB绋嬪簭璁捐姹傛晳T T!!!姹傚ぇ绁!!!
    绛旓細ElseIf Option2.Value = True Then Select Case Int(a * 10) Mod 3 Case 0 '鐭冲ご MsgBox "杈撲簡" Case 1 '鍓垁 MsgBox "骞" Case 2 '甯 MsgBox "璧簡" End Select ElseIf Option3.Value = True Then Select Case Int(a * 10) Mod 3 Case 0...
  • 扩展阅读:新型剪铁皮的电动剪刀 ... 小剪刀抠图软件 ... 大剪刀价格及图片大全 ... 儿歌《石头剪刀布》 ... 形容胖子老二的剪刀图 ... 手工铁皮剪刀 ... 一把剪刀一块石头儿歌 ... 剪果枝专用剪刀 ... 三维看图 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网