当前位置:编程学习 > VB >>

关于 一个程序

    本来在做一个简单的测试程序:两张图片框,开始一张是隐藏的。然后用timer定时在这两张图上画点。用按钮3点一次显示一张,再点一次显示另外一张,这样的一个小程序
     出现几个问题:① 按钮3点击后可以实现交替显示图框,但是里面所画点没有了。
                   ② 我原先目的是在X轴方向每隔距离1画一个点,由变量d控制横坐标,为什么显示后确实那么一大堆,哪里出错了?


三个按钮,一个timer,两个图框

Dim c As Integer, d As Integer

Private Sub Command1_Click()
Timer1.Enabled = True

End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Command3_Click()



If c = 1 Then
 Picture1.Visible = True
 Picture2.Visible = False
   c = c + 1
Else
   If c = 2 Then
    Picture1.Visible = False
    Picture2.Visible = True
    c = c + 1
Else
c = 1
End If
End If

   
End Sub

Private Sub Form_Load()

c = 1
Timer1.Enabled = False
Picture1.Visible = True
Picture2.Visible = True



End Sub

Private Sub Timer1_Timer()
Dim a As Double, b As Double

a = Rnd * 1000
b = Rnd * 1000

Picture1.PSet (d, a)
Picture2.PSet (d, b)
d = d + 1
End Sub
有显示,只是点很小,不明显,你仔细看看左边缘
    With Picture1
        .Visible = True
        .ScaleWidth = vbMillimeters
        .DrawWidth = 2
        .AutoRedraw = True
    End With

    设置显示风格就可以看到 ,picture2 同picture1 
引用 1 楼 veron_04 的回复:
有显示,只是点很小,不明显,你仔细看看左边缘

还有一个为什么每个横坐标内有那么多点啊?
引用 2 楼 king06 的回复:
VB code
    With Picture1
        .Visible = True
        .ScaleWidth = vbMillimeters
        .DrawWidth = 2
        .AutoRedraw = True
    End With

  设置显示风格就可以看到 ,picture2 同picture1

还有为什么每个横坐标会有那么多点,我的原意是一个横坐标对应一个点的
引用 4 楼 zxb234926743 的回复:
引用 2 楼 king06 的回复:
VB code
With Picture1
.Visible = True
.ScaleWidth = vbMillimeters
.DrawWidth = 2
.AutoRedraw = True
End With

设置显示风格就可以看到 ,picture2 同picture1

还有为什么每个横坐标会有那么多点,我的原意是一个横坐标……

没有,就一个,两个Picture不是一样,间隔的. 你程序都是那么写的
补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,