{$Wap} | 平台首页 | 信息必修 | 课程基地 | 通用必修1 | 通用必修2 | 网络 | 多媒体 | 程序 |档案袋 |必修复习 | 网络复习| |编程讨论| |理论测试 |
您现在的位置: 省句中信息技术教学平台 >> 信息必修 >> 第二章 >> 学案 >> 正文
半成品所用代码          【字体:
半成品所用代码
作者:w    文章来源:本站原创    点击数:    更新时间:2005-11-22    

一、体验前进与后退的小车代码:
'定义变量K为整型数据
Dim k As Integer

'小汽车由左向右奔跑
Private Sub cmdgo_Click()
For k = 0 To 3500 Step 1
carImage.Left = k
Next k
End Sub

'小汽车由右向左奔跑
Private Sub cmdback_Click()
For k = 3500 To 0 Step -1
carImage.Left = k
Next k
End Sub


二、高速前进、低速后退

'小汽车高速前进
Private Sub cmdgo_Click()
Dim k As Integer
For k = 0 To 4500 Step 10
carImage.Left = k
Next k
End Sub

'小汽车的初始位置与窗口大小

Private Sub Form_Load()
carImage.Left = 0
Form1.Width = 6000
End Sub


'小汽车低速后退
Private Sub cmdback_Click()
Dim m As Single
For m = 4500 To 0 Step -0.1
carImage.Left = m
Next m
End Sub


三、小车变路线


'定义变量K为整型数据
Dim k As Integer
Dim m As Single
Private Sub Form_Load()
'设置小汽车的起点位置
carImage.Left = 0
'设置窗体的宽度
Form1.Width = 6000
Form1.Height = 3000
End Sub

'小汽车上坡
Private Sub cmdgo_Click()
For k = 0 To 2000 Step 1
  carImage.Left = k
  carImage.Top = 2000 - k
  For m = 1 To 20000
  Next m
Next k
End Sub

'小汽车下坡
Private Sub cmdback_Click()
For k = 2000 To 4000 Step 1
   carImage.Left = k
   carImage.Top = k - 2000
   For m = 1 To 20000
   Next m
Next k
End Sub


扩展一:龟兔赛跑
'开始按钮代码
Private Sub Command3_Click()
Timer1.Enabled = True
End Sub
'停止按钮代码
Private Sub Command4_Click()
Timer1.Enabled = False
End Sub
'复位按钮代码
Private Sub Command5_Click()
Command1.Left = 480
Command2.Left = 480
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Command1.Left = Command1.Left + 80
Command2.Left = Command2.Left + 30
End Sub


 


扩展一:追游戏

‘当鼠标接触到一个按钮时此按钮隐藏,而下一个显示
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Visible = False
Command2.Visible = True

End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command2.Visible = False
Command3.Visible = True

End Sub
Private Sub Command3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command3.Visible = False
Command4.Visible = True

End Sub

Private Sub Command4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command4.Visible = False
Command5.Visible = True

End Sub
Private Sub Command5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command5.Visible = False
Command6.Visible = True

End Sub
Private Sub Command6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command6.Visible = False
Command1.Visible = True

End Sub

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    编程加工第一节课堂安排
    编写代码
    改变属性
    界面设计
    信息的编程加工的过程
    半成品组装视频
    编程加工第二节课任务
    Vb界面介绍
    网络数据库环境构成和工作方
    算法概念的演变
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)