2道VB程式题

来源:百度知道 编辑:UC知道 时间:2024/06/06 18:04:05
2.单击窗体,程序将标签Label1中的字符“Visual Basic程序设计”逐个在窗体上显示。当所有字符在窗体上显示之后,又重复以上过程。
3.设计程序,单击窗体时使文本框在窗体上像走马灯似的流动,当文本框碰到窗体边框时,又反向流动。双击窗体时结束程序。

直接贴上程序源码 其它的我自己做就行了
能做一道是一道 谢谢啊

'第一问
Dim StrT As String, i As Integer

Private Sub Form_Load()
StrT = "Visual Basic程序设计"
Label1.Caption = ""
Label1.AutoSize = True
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
i = i + 1
If i > Len(StrT) Then
i = 1
End If
Label1.Caption = Left(StrT, i)
End Sub

'第二问
Dim TextMove As Boolean, n As Integer

Private Sub Form_Load()
Timer1.Interval = 50 '移动时间间隔
n = 15 * 5 '一次移动5个像素
End Sub

Private Sub Timer1_Timer()
If TextMove = True Then
Text1.Left = Text1.Left + n
Else
Text1.Left = Text1.Left - n
End If

If Text1.Left <= 0 Then
TextMove = True
ElseIf Text1.Left + Text1.Width + 120 >= Me.Width Then
TextMove = False
End If
End Sub