上一题下一题
跳转到
 
 
  世界如此多姿,发展如此迅速,窥一斑未必还能知全豹。但正如万花筒一样,每一个管窥都色彩斑斓。  
 
 
  知识通道 | 学习首页 | 教师首页 | PK首页 | 知识创造首页 | 企业首页 | 登录
 
本文对应知识领域
用VB做定时断线程序
作者:未知 申领版权
2010年11月15日 共有 2524 次访问 【添加到收藏夹】 【我要附加题目
受欢迎度:

    
    运行VB 6,向窗体添加7个Label控件、1个Timer控件、3个Text文本输入框以及4个Command按钮
    
    原理简介:用Timer控件的True或者False值,控制倒计时的开始,当到达设定时间的时候,弹出对话框提示断开连接。
    
    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
    
    下面一段代码是对Timer的控制,以及到设定时间的时候断开连接的代码
    
    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
    
    Timer1.Enabled = False
    
    End If
    
    If Label1.Caption = "00:00:01" Then
    
    dsdklj.WindowState = 0
    
    Command1.Enabled = True
    
    MsgBox "时间到了,正在断开连接"
    
    Dim lngRetCode As Long
    
    Dim lpcb As Long
    
    Dim lpcConnections As Long
    
    Dim intArraySize As Integer
    
    Dim intLooper As Integer
    
    ReDim lprasconn95(intArraySize) As RASCONN95
    
    lprasconn95(0).dwSize = 412
    
    lpcb = 256 * lprasconn95(0).dwSize
    
    lngRetCode = RasEnumConnections(lprasconn95(0), lpcb, lpcConnections)
    
    If lngRetCode = 0 Then
    
    If lpcConnections〉0 Then
    
    For intLooper = 0 To lpcConnections-1
    
    RasHangUp lprasconn95(intLooper).hRasConn
    
    Next intLooper
    
    Unload Me
    
    Else
    
    MsgBox "时间到了,没有拨号网络连接"
    
    Unload Me
    
    End If
    
    End If
    
    End If
    
    End Sub 
    

    

 

相关新闻

您可能对这些感兴趣  

VisualBasic中的界面设计原则和编程技巧
VB6.0与Windows API 间的呼叫技巧
制作可以自动隐藏的弹出式菜单
ListBox中的字符串超长显示的解决方法
VB中的Unicode 和 Ansi 格式
优化程序显示速度
Visual Basic 产生渐层的 Form 背景
用VB实现客户——服务器(TCP/IP)
用VB制作注册软件的方法
VB中的时间处理问题

题目筛选器
日期:
类型:
状态:
得分: <=
分类:
作者:
职业:
关键字:
搜索

 
 
 
  焦点事件
 
  知识体系
 
  职业列表
 
 
  最热文章
 
 
  最多引用文章
 
 
  最新文章
 
 
 
 
网站介绍 | 广告服务 | 招聘信息 | 保护隐私权 | 免责条款 | 法律顾问 | 意见反馈
版权所有 不得转载
沪ICP备 10203777 号 联系电话:021-54428255
  帮助提示    
《我的太学》是一种全新的应用,您在操作中遇到疑问或者问题,请拨打电话13564659895,15921448526。
《我的太学》