史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   VB6 ,有一Command鈕 要如何防止被連擊2次 (http://forum.slime.com.tw/thread225397.html)

飛行船大大 2008-02-20 12:42 PM

VB6 ,有一Command鈕 要如何防止被連擊2次
 
有一Command鈕 click事件內有許多inet的下載作業.
請問 在執行完成作業之前 要如何防止被連擊2次 ??
謝謝~

mini 2008-02-20 02:46 PM

參考看看

語法:

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    hpvDest As Any, _
    ByVal hpvSource As Long, _
    ByVal cbCopy As Long)
Dim gbyteDLData() As Byte
Dim gDataContentLength As Long

==========以上建一個 共用模組.bas==========

Private Sub Inet1_StateChanged(ByVal State As Integer)

On Error GoTo EXITSUB

    Select Case State
    Case icResponseCompleted '此請求已經完成,並且所有資料均已接收到
    Dim tmpB() As Byte
    Dim r As Long

        DoEvents
        '**獲得開頭段資料 及 長度資訊
        Dim S As String
        If gDataContentLength = 0 Then
          gbyteDLData = Inet1.GetChunk(5120, icByteArray)
        End If
        S = Inet1.GetHeader("Content-Length")
        If Len(S) = 0 Then gDataContentLength = 0 Else gDataContentLength = CLng(S)

        '**持續拼接資料,直到無資料為止
        Do While True
          tmpB = Inet1.GetChunk(5120, icByteArray)
          If LenB(tmpB) = 0 Then Exit Do
         
          r = UBound(gbyteDLData) + 1
          ReDim Preserve gbyteDLData(0 To r + UBound(tmpB))
          CopyMemory _
              ByVal VarPtr(gbyteDLData(0)) + r, _
              ByVal VarPtr(tmpB(0)), _
              UBound(tmpB) + 1
             
          Erase tmpB
          DoEvents
        Loop
    End Select
   
EXITSUB:
    If Err.Number = 35758 Then Inet1.Cancel
    Err.Clear

    Command1.Enabled = True
   
End Sub

Private Sub Command1_Click()

    Command1.Enabled = False
    Call StartDownLoad '開始下載副程式

End Sub


ys2230 2010-03-08 03:30 PM

試試看這方法~
 
在你要防止被連擊的_click程式下第一行
Command1.Enabled = False
中間過程放程式~
end sub之前放上這一行
Command1.Enabled = true
即可
:on_79:


所有時間均為台北時間。現在的時間是 09:14 AM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1