跑马灯,VB6代码

Option Explicit
\'直接F5:)
Private Const lDir As Long = -1                   \'方向,+1与-1分别为右转与左转
Dim WithEvents Timer1 As Timer

Private Sub Form_Load()
    \'用代码添加控件并设置控件的初始状态.
\'这样方便点,可以直接粘贴+F5:)
    
    With Me.Controls
        .Add "VB.Label", "Label1"
        .Add "VB.Label", "Label2"
        .Add "VB.PictureBox", "Picture1"
        .Add "VB.Timer", "Timer2"
        Set Timer1 = Me!Timer2
    End With
    
    With Me!Label1
        .AutoSize = True
        .Caption = "<-- 测试测试!@$)(#*%#^*$#@! -->"
        .Visible = True
        Me!Label2.Visible = True
    End With
    
    With Me!Picture1
        .Appearance = 0                           \'Flat
        .Move 1000, 1000, Me!Label1.Width, Me!Label1.Height + 30
        .Visible = True
    End With
    
    With Me!Label1
        Set .Container = Me!Picture1
        Set Me!Label2.Container = Me!Picture1
        
        .Move 0, 0
        Me!Label2.Move .Width, 0, .Width, .Height
        Me!Label2.Caption = .Caption
    End With
    Timer1.Interval = 50
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Static oLab1 As Label, oLab2 As Label
    Dim oTmp As Label
    
    If oLab1 Is Nothing Then Set oLab1 = Me!Label1
    If oLab2 Is Nothing Then Set oLab2 = Me!Label2
    
    If lDir > 0 Then
        If oLab1.Left > oLab1.Width Then
            Set oTmp = oLab1
            Set oLab1 = oLab2
            Set oLab2 = oTmp
        End If
    Else
        If oLab1.Left <= -oLab1.Width Then
            Set oTmp = oLab1
            Set oLab1 = oLab2
            Set oLab2 = oTmp
        End If
    End If
    
    With oLab1
        .Move .Left + 15 * lDir
        oLab2.Move .Left + .Width * (-lDir)
        Me.Caption = .Left & "," & oLab2.Left
    End With
    DoEvents
End Sub