| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 445 人关注过本帖
标题:关于在vb中做3个动圆的问题
只看楼主 加入收藏
seven71
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-4-7
收藏
 问题点数:0 回复次数:0 
关于在vb中做3个动圆的问题
最近在做一个用vb在窗体做3个动圆,这三个圆碰到边界后反弹回去。要求用classmodule做。。这部分代码已经有了,下面不知道该咋做了。。那位帮忙给整下。。我vb太菜了。  在线急等
Option Explicit
Private Name As String
Private intFormIndex As Integer     
Private sglX As Single              
Private sglY As Single            
Private sglXspeed As Single         
Private sglYspeed As Single         
Private sglRadius As Single         

Public Visible As Boolean         

Public Sub Initialize(FormName As String, Optional Top As Single = 1, Optional Left As Single = 1)
    Dim frmBuf As Form
        
   For Each frmBuf In Forms
       If frmBuf.Name = FormName Then
           Exit For
       End If
       intFormIndex = intFormIndex + 1
   Next
   
    sglX = Top
    sglY = Left
    sglRadius = 10
    sglXspeed = 0.1
    sglYspeed = 0.1
   
    Forms(intFormIndex).ScaleMode = vbMillimeters
        
    Visible = True
   
End Sub

Public Sub WriteCircle(Top As Single, Left As Single)
    If Not Visible Then Exit Sub
    sglX = Top
    sglY = Left
   
    frmMain.FillStyle = 0
    frmMain.FillColor = vbGreen
    frmMain.Circle (sglX, sglY), sglRadius
        
End Sub

Public Property Let X(Xpos As Single)
    sglX = Xpos
End Property

Public Property Get X() As Single
    X = sglX
End Property

Public Property Let Y(Ypos As Single)
    sglY = Ypos
End Property

Public Property Get Y() As Single
    Y = sglY
End Property

Public Property Let XSpeed(Xpos As Single)
    If Xpos < -10 Or Xpos > 10 Then
        Err.Raise 10000, "", "请输入-10到10之间的数字。"
    End If
   
    sglXspeed = Xpos
End Property

Public Property Get XSpeed() As Single
    XSpeed = sglXspeed
End Property

Public Property Let YSpeed(Ypos As Single)
    If Ypos < -10 Or Ypos > 10 Then
        Err.Raise 10000, "", "请输入-10到10之间的数字。"
    End If
   
    sglYspeed = Ypos
End Property

Public Property Get YSpeed() As Single
    YSpeed = sglYspeed
End Property
2008-04-07 12:01
快速回复:关于在vb中做3个动圆的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030020 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved