导航:首页 > 编程语言 > 趣味vb编程

趣味vb编程

发布时间:2022-01-12 22:41:45

❶ 小游戏vb编程

贪吃蛇
PrivateSubForm_KeyDown(KeyCodeAsInteger,ShiftAsInteger)
DimCAsLong
IfKeyCode=27ThenEnd
IfKeyCode=32Then
IfTimer1.Enabled=TrueThen
Timer1.Enabled=False
Label1.Visible=True
Else
Timer1.Enabled=True
Label1.Visible=False
EndIf
EndIf
C=UBound(She)
IfGFangXiang=TrueThenExitSub
SelectCaseKeyCode
Case37
IfShe(C).F=2ThenExitSub
She(C).F=0
GFangXiang=True
Case38
IfShe(C).F=3ThenExitSub
She(C).F=1
GFangXiang=True
Case39
IfShe(C).F=0ThenExitSub
She(C).F=2
GFangXiang=True
Case40
IfShe(C).F=1ThenExitSub
She(C).F=3
GFangXiang=True
EndSelect
EndSub

PrivateSubForm_Load()
Me.AutoRedraw=True
Me.BackColor=&HC000&
Me.FillColor=255
Me.FillStyle=0
Me.ScaleWidth=24
Me.ScaleHeight=24
Me.WindowState=2
SetTimer1=Controls.Add("VB.Timer","Timer1")
SetLabel1=Controls.Add("VB.Label","Label1")
Label1.AutoSize=True
Label1.BackStyle=0
Label1="暂停"
Label1.ForeColor=RGB(255,255,0)
Label1.FontSize=50
ChuShiHua
EndSub

PrivateSubForm_Resize()
OnErrorGoTo1:
WithMe
If.WindowState<>1Then
.Cls
.ScaleMode=3
HWB=.ScaleHeight/.ScaleWidth
.ScaleWidth=24
.ScaleHeight=24
Label1.Move(Me.ScaleWidth-Label1.Width)/2,(Me.ScaleHeight-Label1.Height)/2
HuaTu
Me.Line(X,Y)-(X+1,Y+1),RGB(255,255,0),BF
EndIf
EndWith
1:
EndSub

PrivateSubTimer1_Timer()
DimCAsLong,IAsLong
OnErrorGoTo2:
QingChu
C=UBound(She)
SelectCaseShe(C).F
Case0
IfZhuangTai(She(C).X-1,She(C).Y)=2Then
C=C+1
ReDimPreserveShe(C)
She(C).F=She(C-1).F
She(C).X=She(C-1).X-1
She(C).Y=She(C-1).Y
ChanShengShiWu
GoTo1:
ElseIfZhuangTai(She(C).X-1,She(C).Y)=1Then
GoTo2:
EndIf
Case1
IfZhuangTai(She(C).X,She(C).Y-1)=2Then
C=C+1
ReDimPreserveShe(C)
She(C).F=She(C-1).F
She(C).X=She(C-1).X
She(C).Y=She(C-1).Y-1
ChanShengShiWu
GoTo1:
ElseIfZhuangTai(She(C).X,She(C).Y-1)=1Then
GoTo2:
EndIf
Case2
IfZhuangTai(She(C).X+1,She(C).Y)=2Then
C=C+1
ReDimPreserveShe(C)
She(C).F=She(C-1).F
She(C).X=She(C-1).X+1
She(C).Y=She(C-1).Y
ChanShengShiWu
GoTo1:
ElseIfZhuangTai(She(C).X+1,She(C).Y)=1Then
GoTo2:
EndIf
Case3
IfZhuangTai(She(C).X,She(C).Y+1)=2Then
C=C+1
ReDimPreserveShe(C)
She(C).F=She(C-1).F
She(C).X=She(C-1).X
She(C).Y=She(C-1).Y+1
ChanShengShiWu
GoTo1:
ElseIfZhuangTai(She(C).X,She(C).Y+1)=1Then
GoTo2:
EndIf
EndSelect
ZhuangTai(She(0).X,She(0).Y)=0
ForI=0ToC
SelectCaseShe(I).F
Case0
She(I).X=She(I).X-1
Case1
She(I).Y=She(I).Y-1
Case2
She(I).X=She(I).X+1
Case3
She(I).Y=She(I).Y+1
EndSelect
Next
TiaoZheng
1:
GFangXiang=False
ZhuangTai(She(C).X,She(C).Y)=1
HuaTu
ExitSub
2:
IfMsgBox("游戏结束,点“是”重新开始游戏,点“否”",vbYesNo,"贪吃蛇")=vbYesThen
ChuShiHua
Else
End
EndIf
EndSub

PrivateSubChuShiHua()
Me.Cls
Timer1.Enabled=True
Timer1.Interval=200
EraseZhuangTai
ReDimShe(2)
She(0).F=2
She(0).X=9
She(0).Y=11
ZhuangTai(9,11)=1
She(1).F=2
She(1).X=10
She(1).Y=11
ZhuangTai(10,11)=1
She(2).F=2
She(2).X=11
She(2).Y=11
ZhuangTai(11,11)=1
HuaTu
ChanShengShiWu
EndSub

PrivateSubQingChu()
DimIAsLong
ForI=0ToUBound(She)
Me.Line(She(I).X,She(I).Y)-(She(I).X+1,She(I).Y+1),Me.BackColor,BF
Next
EndSub

PrivateSubHuaTu()
DimIAsLong
ForI=0ToUBound(She)
Me.Circle(She(I).X+0.5,She(I).Y+0.5),0.49,RGB(255,255,0),,,HWB
Next
EndSub

PrivateSubTiaoZheng()
DimIAsLong
ForI=0ToUBound(She)-1
She(I).F=She(I+1).F
Next
EndSub

PrivateSubChanShengShiWu()
RandomizeTimer
1:
X=Int(Rnd*24)
Y=Int(Rnd*24)
IfZhuangTai(X,Y)>0ThenGoTo1:
ZhuangTai(X,Y)=2
Me.Line(X,Y)-(X+1,Y+1),RGB(255,255,0),BF
EndSub

❷ 趣味VB编程

好弱啊……哪来得这么无聊的题……form1中放俩shape,shape1在zhape2底下,再放3timer。不用改属性,load里写好了 Private Sub Form_Load()
Timer1.Interval = 200
Timer2.Interval = 50
Timer2.Enabled = False
Shape2.Shape = 3
Timer3.Enabled = False
Timer3.Interval = 200
Shape2.Left = 0.5 * Form1.WidthEnd SubPrivate Sub Timer1_Timer()
If Shape1.Left < 0.5 * Form1.Width Then
Shape1.Left = Shape1.Left + 100
Else
If i = 0 Then Timer2.Enabled = True
i = i + 1
Me.Enabled = False
End If
End SubPrivate Sub Timer2_Timer()If Shape2.Top <= Shape1.Top Then
Shape2.Top = Shape2.Top + 100
Else
Timer3.Enabled = True
End If
End SubPrivate Sub Timer3_Timer()
Shape1.Left = Shape1.Left + 100
Shape2.Left = Shape2.Left + 100
End Sub
背景啥的自己放挖,或者给我素材

❸ VB,我做了个趣味的小程序 加法错误。

Dim a As Single, b As Single, c As Single

Private Sub c1_Click()
S1.Enabled = True
End Sub

Private Sub s1_Timer()
Randomize
upperbound = 10
lowerbound = 1
T1.Text = Val(Int((upperbound - lowerbound + 1) * Rnd + lowerbound))
a = Val(T1.Text)

Randomize
upperbound = 10
lowerbound = 1
T2.Text = Val(Int((upperbound - lowerbound + 1) * Rnd + lowerbound))
b = Val(T2.Text)

c = a + b
L4.Caption = c
End Sub

❹ 编程vb趣味程序"计算厚道指数"怎么算

250分,非常厚道
200分,很厚道
150分,还算厚道
100分,几乎厚道
50分,小气鬼

至于一分都没有的楼主,就是最不厚道的人了。
0分还来问编程?完全是脱离了厚道进入了搞笑。

❺ VB趣味题

不难嘛:
'首先是输入买的商品值:
a=inputbox("输入买的商品值")
a=val(a)
'下面是计算方法:
'第一种:
if a>=1000 then b=0.95
if a>=2000 then b=0.9
if a>=3000 then b=0.85
if a>=5000 then b=0.8
a=a*b
'第二种:
if a>=1000 and <2000 then
a=a*0.95
elseif a>=2000 and a<3000 then
a=a*0.9
elseif a>=3000 and a<5000 then
a=a*0.85
elseif a>=5000 then
a=a*0.8
end if
'最后得出的a就是打折后的钱

❻ vb 程序设计 趣味填数

Private Sub Command1_Click() ‘单击执行
Picture1.Cls
Dim i As Integer, m As Integer, n As Integer, q As Integer, w As Integer
Dim j As Integer, l As Integer
Dim k As Integer
Dim ds As Single, sd As Single
k = 1
b = Val(Text1.Text)
a = Val(Text2.Text)
If b < 2 Or b > 30 Then ’根据输入的数据来判断是否在正确的范围内,不正确则返回
MsgBox "请输入正确的值"
GoTo dny:
End If
If a < 2 Or a > 20 Then ’根据输入的数据来判断是否在正确的范围内,不正确则返回 MsgBox "请输入正确的值"
GoTo dny:
End If
ReDim s(1 To a, 1 To b) As Integer

Select Case c ’根据输入的数据值来判断该执行什么计算操作
case -1
MsgBox ("请选择项目")
Case 0
Const pi As Single = 3.14159265
Dim x&, y&, z&, t#
ReDim s(a + 1, b + 1) As Integer
For x = 0 To a + 1 ’初始化数据
s(x, 0) = -1
s(x, b + 1) = -1
Next x
For y = 0 To b + 1 ‘初始化数据
s(0, y) = -1
s(a + 1, y) = -1
Next y
x = 1: y = 1: t = 0: s(x, y) = 1
For z = 2 To a * b
If s(x + Round(Sin(t)), y + Round(Cos(t))) = 0 Then
x = x + Round(Sin(t))
y = y + Round(Cos(t))
s(x, y) = z
Else
t = t + pi / 2
z = z - 1
End If
Next z
Case 1 ’具体数据计算
k = 1
For i = 1 To b * a
j = j + 1
If k Mod 2 = 1 Then
s(j, k) = i
ElseIf k Mod 2 = 0 Then
s(a - j + 1, k) = i
End If
If j >= a Then
j = 0
k = k + 1
End If
Next i
Case 2
k = 1
For i = 1 To b * a
j = j + 1
If k Mod 2 = 1 Then
s(k, j) = i
ElseIf k Mod 2 = 0 Then
s(k, b - j + 1) = i
End If
If j = b Then
j = 0
k = k + 1
End If
Next i
End Select
For x = 1 To a
For y = 1 To b
Picture1.FontSize = Picture1.Height / Int(a * 36) ‘数据输出
Picture1.Print Format(s(x, y), "@@@@@");
Next
Picture1.Print
Next

dny:
End Sub

❼ 介绍一个VB小的有趣的程序代码

'万花筒程序
'粘贴下面代码即可, 不用添加任何控件
Private WithEvents Timer1 As Timer
Dim r&, r1&, t&, a1!, a2!, xb!, yb!, s!, b#
Private Sub Form_Load()
Me.Width = 4500: Me.Height = 4500
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
Me.AutoRedraw = True
Me.Caption = "CBM666的万花筒"
Set Timer1 = Controls.Add("vb.timer", "Timer1")
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
Randomize
r = 340 * Rnd
If r <> 0 Then
r1 = 500
s = r * Rnd
b = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
For t = 1 To 10000
a1 = t * 3.1415926 / 180
a2 = (r1 / r) * a1
xb = 500 + (-(r1 - r) * Cos(a1) - s * Cos(a2 - a1) + 420) * 4
yb = 500 + ((r1 - r) * Sin(a1) - s * Sin(a2 - a1) + 380) * 4
Me.PSet (xb, yb), b
Next t
End If
End Sub

❽ 用VB编写一个小游戏

'定义蛇的运动速度枚举值
Private Enum tpsSpeed
QUICKLY = 0
SLOWLY = 1
End Enum

'定义蛇的运动方向枚举值
Private Enum tpsDirection
D_UP = 38
D_DOWN = 40
D_LEFT = 37
D_RIGHT = 39
End Enum

'定义运动区域4个禁区的枚举值
Private Enum tpsForbiddenZone
FZ_TOP = 30
FZ_BOTTOM = 5330
FZ_LEFT = 30
FZ_RIGHT = 5730
End Enum

'定义蛇头及身体初始化数枚举值
Private Enum tpsSnake
SNAKEONE = 1
SNAKETWO = 2
SNAKETHREE = 3
SNAKEFOUR = 4
End Enum

'定义蛇宽度的常量
Private Const SNAKEWIDTH As Integer = 100

'该过程用于显示游戏信息
Private Sub Form_Load()
Me.Show
Me.lblTitle = "BS贪食蛇 — (版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")"
Me.Caption = Me.lblTitle.Caption
frmSplash.Show 1
End Sub

'该过程用于使窗体恢复原始大小
Private Sub Form_Resize()
If Me.WindowState > 1 Then
Me.Caption = ""
Me.Height = 6405 '窗体高度为 6405 缇
Me.Width = 8535 '窗体宽度为 8535 缇
Me.Left = (Screen.Width - Width) \ 2
Me.Top = (Screen.Height - Height) \ 2
End If
End Sub

'该过程用于重新开始开始游戏
Private Sub cmdGameStart_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您确认要重新开始游戏吗?", 4 + 32, "BS贪食蛇")
If msg = 6 Then Call m_subGameInitialize
End Sub

'该过程用于暂停/运行游戏
Private Sub chkPause_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.chkPause.Caption = "暂停游戏(&P)" Then
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Enabled = False
Me.lblPauseLab.Visible = True
Me.chkPause.Caption = "继续游戏(&R)"
Else
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Me.picMoveArea.Enabled = True
Me.lblPauseLab.Visible = False
Me.chkPause.Caption = "暂停游戏(&P)"
End If
End Sub

'该过程用于显示游戏规则
Private Sub cmdGameRules_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox " BS贪食蛇:一个规则最简单的趣味游戏,您将用键盘" & Chr(13) & _
"上的4个方向键来控制蛇的运动方向。在运动过程中蛇" & Chr(13) & _
"不能后退,蛇的头部也不能接触到运动区域的边线以外" & Chr(13) & _
"和蛇自己的身体,否则就游戏失败。在吃掉随机出现的" & Chr(13) & _
"果子后,蛇的身体会变长,越长难度越大。祝您好运!!", 0 + 64, "游戏规则"
End Sub

'该过程用于显示游戏开发信息
Private Sub cmdAbout_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox "BS贪食蛇" & "(V-" & App.Major & "." & App.Minor & "版本)" & Chr(13) & Chr(13) & _
"" & Chr(13) & Chr(13) & _
"由PigheadPrince设计制作" & Chr(13) & _
"CopyRight(C)2002,BestSoft.TCG", 0, "关于本游戏"
End Sub

'该过程用于退出游戏
Private Sub cmdExit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您要退出本游戏吗?", 4 + 32, "BS贪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Sub

'该过程用于拖动窗体_(点击图标)
Private Sub imgWindowTop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MOVE, 0
End Sub

'该共用过程用于处理窗体控制按钮组的相关操作_(锁定、最小化、退出)
Private Sub chkWindowButton_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button > 1 Then Exit Sub
Select Case Index
Case 0 '锁定窗体
If Me.chkWindowButton(0).Value = 1 Then
Me.imgWindowTop.BorderStyle = 0
Me.imgWindowTop.Enabled = False
Else
Me.imgWindowTop.BorderStyle = 1
Me.imgWindowTop.Enabled = True
End If
Case 1 '最小化
Me.WindowState = 1
Me.chkWindowButton(1).Value = 0
Me.Caption = "BS贪食蛇 — (V-" & App.Major & "." & App.Minor & "版本)"
Case 2 '退出
Beep
msg = MsgBox("您要退出本游戏吗?", 4 + 32, "BS贪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Select
End Sub

'该过程用于设置蛇运动速度的快慢
Private Sub hsbGameSpeed_Change()
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
End Sub

'该过程用于通过键盘的方向键改变蛇的运动方向
Private Sub picMoveArea_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case g_intDirection
Case D_UP
If KeyCode = D_DOWN Then Exit Sub
Case D_DOWN
If KeyCode = D_UP Then Exit Sub
Case D_LEFT
If KeyCode = D_RIGHT Then Exit Sub
Case D_RIGHT
If KeyCode = D_LEFT Then Exit Sub
End Select
g_intDirection = KeyCode
End Sub

'该计时循环过程用于计算游戏耗费的秒数并显示
Private Sub tmrGameTime_Timer()
g_lngGameTime = g_lngGameTime + 1
Me.lblGameTime.Caption = g_lngGameTime & "秒"
End Sub

'该计时循环过程用于控制蛇的行动轨迹
Private Sub tmrSnakeMove_Timer()
Dim lngSnakeX As Long, lngSnakeY As Long, lngSnakeColor As Long
Dim lngPointX As Long, lngPointY As Long, lngPointColor As Long
Randomize
Me.picMoveArea.SetFocus
Me.picMoveArea.Cls
'确认蛇头的运动方向并获取新的位置
Select Case g_intDirection
Case D_UP '向上运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY - SNAKEWIDTH
Case D_DOWN '向下运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY + SNAKEWIDTH
Case D_LEFT '向左运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX - SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
Case D_RIGHT '向右运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX + SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
End Select
'根据新的位置绘制蛇头
lngSnakeX = g_udtSnake(SNAKEONE).Snake_CurX
lngSnakeY = g_udtSnake(SNAKEONE).Snake_CurY
lngSnakeColor = g_udtSnake(SNAKEONE).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
'移动蛇身体其他部分的位置
For i = 2 To g_intSnakeLength
g_udtSnake(i).Snake_CurX = g_udtSnake(i - 1).Snake_OldX
g_udtSnake(i).Snake_CurY = g_udtSnake(i - 1).Snake_OldY
lngSnakeX = g_udtSnake(i).Snake_CurX
lngSnakeY = g_udtSnake(i).Snake_CurY
lngSnakeColor = g_udtSnake(i).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
Next i
'更新蛇旧的坐标位置
For j = 1 To g_intSnakeLength
g_udtSnake(j).Snake_OldX = g_udtSnake(j).Snake_CurX
g_udtSnake(j).Snake_OldY = g_udtSnake(j).Snake_CurY
Next j
'判断蛇在移动中是否到了禁区而导致游戏失败
If m_funMoveForbiddenZone(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇移动到了禁区,游戏失败!", 0 + 16, "BS贪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判断蛇在移动中是否碰到了自己的身体而导致游戏失败
If m_funTouchSnakeBody(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇在移动中碰到了自己的身体,游戏失败!", 0 + 16, "BS贪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判断蛇是否吃到了果子
If m_funEatPoint(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
'累加玩家的得分并刷新得分显示
g_intPlayerScore = g_intPlayerScore + 1
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Call m_subAddSnake '加长蛇的身体
Call m_subGetPoint '获取下一个果子的位置和颜色
Else
'绘制果子
lngPointX = g_udtPoint.Point_X
lngPointY = g_udtPoint.Point_Y
lngPointColor = g_udtPoint.Point_Color
Me.picMoveArea.PSet (lngPointX, lngPointY), lngPointColor
End If
End Sub

'该私有子过程用于初始化游戏
Private Sub m_subGameInitialize()
Erase g_udtSnake '清空蛇的结构数组
g_intPlayerScore = 0 '清空玩家的得分
g_lngGameTime = 0 '清空游戏耗费的秒数
g_intDirection = D_DOWN '设定蛇的初始运动方向为下
g_intSnakeLength = 4 '设定蛇的初始长度
ReDim g_udtSnake(1 To g_intSnakeLength) '重新定义蛇的长度
'定义蛇头部的数据
With g_udtSnake(SNAKEONE)
.Snake_OldX = 530
.Snake_OldY = 530
.Snake_Color = vbBlack
End With
'定义蛇身第2节的数据
With g_udtSnake(SNAKETWO)
.Snake_OldX = 530
.Snake_OldY = 430
.Snake_Color = vbGreen
End With
'定义蛇身第3节的数据
With g_udtSnake(SNAKETHREE)
.Snake_OldX = 530
.Snake_OldY = 330
.Snake_Color = vbYellow
End With
'定义蛇身第4节的数据
With g_udtSnake(SNAKEFOUR)
.Snake_OldX = 530
.Snake_OldY = 230
.Snake_Color = vbRed
End With
Me.picMoveArea.Visible = True
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Me.lblGameTime.Caption = g_lngGameTime & "秒"
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Call m_subGetPoint '获取第一个果子的位置和颜色
End Sub

'该私有子过程用于返回获取的果子的位置和颜色信息
Private Sub m_subGetPoint()
Dim lngRedValue As Long, lngGreenValue As Long, lngBlueValue As Long
Dim lngPointX As Long, lngPointY As Long, lngPointColor As Long
'随机获取果子的颜色
lngRedValue = Int((255 - 0 + 1) * Rnd + 0)
lngGreenValue = Int((255 - 0 + 1) * Rnd + 0)
lngBlueValue = Int((255 - 0 + 1) * Rnd + 0)
lngPointColor = RGB(lngRedValue, lngGreenValue, lngBlueValue)
'随机获取果子的位置
lngPointX = Int((FZ_LEFT - FZ_RIGHT + 1) * Rnd + FZ_RIGHT)
lngPointY = Int((FZ_TOP - FZ_BOTTOM + 1) * Rnd + FZ_BOTTOM)
Me.PSet (lngPointX, lngPointY), lngPointColor
'设置函数返回值
With g_udtPoint
.Point_X = lngPointX
.Point_Y = lngPointY
.Point_Color = lngPointColor
End With
End Sub

❾ VB编程,超简单的。求编写代码

第一题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入当前顾客购买鸡蛋的重量(以公斤为单位)")
If x < 3 Then
Y = 7.6 * x
Else
Y = 7.6 * x * 0.8
End If
Print Format(Y, "0.00")
End Sub

第二题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入顾客所乘的公里数")
If x / Fix(x) = 1 Then
x = x
Else
x = Fix(x) + 1
End If

If x > 15 Then
Y = 7 + 13 * 1.5 + (x - 15) * 2.1
ElseIf x > 2 Then
Y = 7 + (x - 2) * 1.5
Else
Y = 7
End If

Print Y
End Sub

❿ vb编程超简单

PrivateSubCommand1_Click()
Text2.Text=""
Text2.Text=Text2.Text+Text1.Text
Fori=0To2
IfOption1(i).Value=TrueThen
Text2.Text=Text2.Text+Space(3)+"职称:"+Option1(i).Caption+Space(3)
Else
Option1(i).Enabled=False
EndIf
Nexti
Text2.Text=Text2.Text+"爱好:"
Fori=0To2
IfCheck1(i).Value=1Then
Text2.Text=Text2.Text+Check1(i).Caption+Space(1)
Else
Check1(i).Enabled=False
EndIf
Nexti
Text2.Text=Text2.Text+Space(2)+"籍贯:"+List1.List(List1.ListIndex)+Space(3)
Text2.Text=Text2.Text+"部门:"+Combo1.Text
EndSub

PrivateSubCommand2_Click()
End
EndSub

PrivateSubForm_Load()
Option1(0).Caption="初级"
Option1(1).Caption="中级"
Option1(2).Caption="高级"
Check1(0).Caption="音乐"
Check1(1).Caption="体育"
Check1(2).Caption="绘画"
List1.AddItem"北京市"
List1.AddItem"江苏省"
List1.AddItem"江西省"
List1.AddItem"山东省"
List1.AddItem"山西省"
List1.AddItem"浙江省"
List1.AddItem"辽宁省"
List1.AddItem"天津市"
List1.AddItem"湖南省"
List1.AddItem"河北省"
List1.AddItem"上海市"
List1.AddItem"广东省"
Combo1.AddItem"电子系"
Combo1.AddItem"数学系"
Combo1.AddItem"计算机系"
Combo1.AddItem"物理系"
Combo1.AddItem"化学系"
Combo1.AddItem"天文系"
Combo1.AddItem"地质系"
Combo1.AddItem"医学系"
Text1.Text=""
Text2.Text=""

EndSub

PrivateSubFrame1_Click()
Fori=0To2
IfOption1(Index).Value=FalseThenOption1(Index).Enabled=False
Nexti
EndSub

阅读全文

与趣味vb编程相关的资料

热点内容
pdf光子 浏览:832
自拍软件文件夹名称大全 浏览:325
程序员留学移民 浏览:49
梁中间部位箍筋加密区 浏览:117
频谱分析pdf 浏览:750
乐2怎么升级安卓70 浏览:172
java中获取日期 浏览:506
单片机74hc245 浏览:272
美国历史上的总统pdf 浏览:751
程序员脱单实验室靠不靠谱 浏览:458
php中间四位手机号 浏览:870
永旺app怎么样了 浏览:516
压缩空气流量计算软件 浏览:650
智慧聊天app怎么激活 浏览:924
一加换机备份到哪个文件夹 浏览:736
支撑pdf 浏览:417
java空文件夹删除 浏览:587
安卓9跟81有什么区别 浏览:912
n1蓝宝书pdf 浏览:245
为什么安卓机拍照那么丑 浏览:696