解除網(wǎng)蟲心病VB做定時(shí)斷線程序

字號(hào):

運(yùn)行VB 6,向窗體添加7個(gè)Label控件、1個(gè)Timer控件、3個(gè)Text文本輸入框以及4個(gè)Command按鈕。
    原理簡(jiǎn)介:用Timer控件的True或者False值,控制倒計(jì)時(shí)的開始,當(dāng)?shù)竭_(dá)設(shè)定時(shí)間的時(shí)候,彈出對(duì)話框提示斷開連接。
    Option Explicit
    Dim Hours As Integer
    Dim Minutes As Integer
    Dim Seconds As Integer
    Dim time As Date
    Private Declare Function RasHangUp Lib "RaSAPi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
    Private Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lprasconn As Any, lpcb As Long, lpcConnections As Long) As Long
    Const RAS95_MaxEntryName = 256
    Const RAS95_MaxDeviceName = 128
    Const RAS_MaxDeviceType = 16
    Private Type RASCONN95
    dwSize As Long
    hRasConn As Long
    szEntryName(RAS95_MaxEntryName) As Byte
    szDeviceType(RAS_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
    End Type
    下面一段代碼是對(duì)Timer的控制,以及到設(shè)定時(shí)間的時(shí)候斷開連接的代碼
    Private Sub Timer1_Timer()
    Timer1.Enabled = False
    If (Format100 100time, "hh") && ":" && Format100 100time, "nn") && ":" && Format100 100time, "ss"))〈〉"00:00:00" Then
    time = DateAdd("s", -1, time)
    Label1.Visible = False
    Label1.Caption = Format100 100time, "hh") && ":" && Format100 100time, "nn") && ":" && Format100 100time, "ss")
    Label1.Visible = True
    Timer1.Enabled = True
    Else