建一个文本文档,输入以下代码,后缀改为.frm用枣腔纯vb打开就可以了
以下是程序源码凳咐:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "猜数游戏"
ClientHeight= 3900
ClientLeft = 45
ClientTop = 435
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3900
ScaleWidth = 4680
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "重新圆并开始"
Height = 615
Left= 2640
TabIndex= 2
Top = 2760
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 615
Left= 840
TabIndex= 1
Top = 2760
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left= 1200
TabIndex= 0
Top = 2040
Width = 2055
End
Begin VB.Label Label9
Caption = "戏"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 615
Left= 3720
TabIndex= 11
Top = 240
Width = 615
End
Begin VB.Label Label8
Caption = "游"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00808080&
Height = 615
Left= 3240
TabIndex= 10
Top = 240
Width = 615
End
Begin VB.Label Label7
Caption = "数"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 495
Left= 2760
TabIndex= 9
Top = 240
Width = 615
End
Begin VB.Label Label6
Caption = "猜"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF00FF&
Height = 495
Left= 2280
TabIndex= 8
Top = 240
Width = 735
End
Begin VB.Label Label5
Caption = "入"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 615
Left= 1800
TabIndex= 7
Top = 240
Width = 855
End
Begin VB.Label Label4
Caption = "进"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 735
Left= 1320
TabIndex= 6
Top = 240
Width = 735
End
Begin VB.Label Label3
Caption = "迎"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFF00&
Height = 735
Left= 840
TabIndex= 5
Top = 240
Width = 735
End
Begin VB.Label Label2
Caption = "欢"
BeginProperty Font
Name= "宋体"
Size= 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 615
Left= 360
TabIndex= 4
Top = 240
Width = 495
End
Begin VB.Label Label1
Caption = "我这儿有1~10的整数,你猜猜看他是多少......"
Height = 375
Left= 480
TabIndex= 3
Top = 1320
Width = 3855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x As Integer, y As Integer, z As Integer
Dim cishu As Integer
Private Sub Command1_Click()
If cishu = 3 Then MsgBox "已经猜3次了,这个数是" &x: Exit Sub
y = Val(Text1.Text)
If Text1.Text = "" Or Not IsNumeric(Text1.Text) Then
MsgBox "输入有误!请重新输入数字", 48
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
cishu = cishu + 1
Select Case x - y
Case Is <0
z = MsgBox("你猜数大了,请重猜。注意:你只有三次机会", 48 + 1)
Text1.Text = ""
Text1.SetFocus
Case Is >0
z = MsgBox("你猜数小了,请重猜。注意:你只有三次机会", 48 + 1)
Text1.Text = ""
Text1.SetFocus
Case Else
z = MsgBox("恭喜你猜中了!", 1)
End Select
End Sub
Private Sub Command2_Click()
cishu = 0
Randomize Timer
x = Int((Rnd * 10) + 1)
End Sub
Private Sub Form_Load()
cishu = 0
Randomize Timer
x = Int((Rnd * 10) + 1)
End Sub
代码结束
http://hi.baidu.com/卓7358/
欢迎来我空间
1、提取:用这个vb小程序可以!
2、网页显示(必须先用上面程序将源码保存为txt,并且在打开窗口里选择该txt文件!):
拖进一个webbrowser1,一个commondialog1,一个command1.
Private Sub Command1_Click()
CommonDialog1.ShowOpen
WebBrowser1.Navigate (CommonDialog1.FileName)
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)