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

关于循环的问题

我想添加一个循环,并切在第2次按空格后,才停止循环,并且删除当前获得图片的地址.请高手指教
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
Dim a As String
Dim j As Integer
Dim i As Integer
For i = 0 To Form2.List1.ListCount
j = Rnd * (Form2.List1.ListCount - 1)
a = Form2.List1.List(j)
Form1.Image2.Picture = LoadPicture(a)
DoEvents
Next
End If
End Sub --------------------编程问答-------------------- Option Explicit
Dim SpaceCount As Integer


Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = 32 Then SpaceCount = SpaceCount - 1
End Sub

Private Sub Form_Paint()
    SpaceCount = 2
    MsgBox "begin"
    '循环,直到按下两次空格键
    Do
        DoEvents
        If SpaceCount < 0 Then Exit Do
        DoEvents
    Loop
    MsgBox "end"
End Sub
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,