原题就是用VB编一个在电脑屏幕上每隔5秒钟显示一行字,这一行字每次得显示一秒钟

解决方案 »

  1.   

    把timer的interval由5000修改为1000。
      

  2.   


    Option Explicit
    Dim istr As StringPrivate Sub Form_Load()
       Timer1.Enabled = False
       Timer1.Interval = 5000
       istr = "abc|def|ghi"
       Text1 = ""
       Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
       Static f As Boolean, n As Byte
       If Not f Then
          Text1 = Split(istr, "|")(n)
          n = n + 1
          If n = 3 Then n = 0
          Timer1.Interval = 1000
       
       Else
          Text1 = ""
          Timer1.Interval = 5000
       End If
       f = Not f
         
    End Sub
      

  3.   

    设置窗体的BorderStyle属性为0Option Explicit
    '窗体透明声明
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    Private Const WS_EX_LAYERED = &H80000
    Private Const GWL_EXSTYLE = (-20)
    Private Const LWA_COLORKEY = &H1Private Sub Form_Load()
    '    Me.BorderStyle = 0
        '透明实现部分,可将下面的vbBlue改成窗体上(包括所有控件)任一一个不用的颜色
        Form1.BackColor = vbBlue   'vbBlue
        Dim rtn As Long
        rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
        rtn = rtn Or WS_EX_LAYERED
        SetWindowLong hwnd, GWL_EXSTYLE, rtn
        SetLayeredWindowAttributes hwnd, vbBlue, 0, LWA_COLORKEY   'vbBule
        
        Label1.BackStyle = 0
        Label1.Visible = False
        Timer2.Enabled = False
        Timer2.Interval = 1000
        Timer1.Interval = 5000
        Timer1.Enabled = True
    End Sub
    Private Sub Timer1_Timer()
        Static intNum As Integer
        intNum = intNum + 1
        
        Label1.Visible = True
        Label1.Caption = "Hello world"
        Timer2.Enabled = True
        
        If intNum > 5 Then
            Unload Me
        End If
        
    End SubPrivate Sub Timer2_Timer()
        Label1.Visible = False
        Label1.Caption = ""
        Timer2.Enabled = True
    End Sub
      

  4.   

    '添加一个窗体form1,窗体backcolor属性设置为&H00FF0000&,borderstyle属性设置为0;添加一个label1,backstyle属性设置为0;添加一个timer1,interval属性设置为1000,然后添加如下代码:
    Option ExplicitPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    Const WS_EX_LAYERED = &H80000
    Const GWL_EXSTYLE = (-20)
    Const LWA_COLORKEY = &H1
    Const LWA_ALPHA = &H2
    Const LWA_COLORKEY_ALPHA = &H3Dim strData$, vPrivate Sub Form_Load()
        strData = "一段美轮美奂的爱情深刻的爱情" & vbCrLf & _
                "你带我去看最美的风景" & vbCrLf & _
                "转动在这个摩天轮里还有你送我的玩具" & vbCrLf & _
                "爱上伦敦的清晰爱也很清晰" & vbCrLf & _
                "双手的温度填满在心里" & vbCrLf & _
                "纵使我们终究会是分开记得彼此的心"
        v = Split(strData, vbCrLf)    Dim rtn&, transcolor&
        rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
        rtn = rtn + WS_EX_LAYERED
        SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
        SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
        
        SetLayeredWindowAttributes Me.hwnd, &HFF0000, 0, LWA_COLORKEY
    End Sub
    '双击文字退出
    Private Sub Label1_DblClick()
        End
    End SubPrivate Sub Timer1_Timer()
        Static i%
        Label1.Caption = v(i)
        i = i + 1
        If i > UBound(v) Then i = 0
    End Sub
      

  5.   

    正解,只需一个timer就行了。
      

  6.   

    代码下载:
    http://download.csdn.net/source/2890760