论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP Java Web .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 安卓APP 其他 C# 代写论文
当前位置: > 计算机 > VB6.0 >

A450vb校园网交换机节点管理系统+论文

5.3 定时功能的实现

VB提供了一种“计时器”的控件,用来计时,计时器每隔一定时间间隔就产生一次Timer事件,可能根据这个特性按时间控制某些操作。Timer 控件最重要的是 Interval 即时间间隔属性。该属性决定了时钟事件之间的间隔,以毫秒为单位,取值范围为0 ~ 65535 ,因此其最大时间间隔不能超过 65 秒,即一分钟多一点的时间。 内容来自论文无忧网 www.paper51.com

在该程序中,把 Interval 属性设置为 1000 ,则表示每秒钟触发一个Timer 事件。每次产生Timer事件时都往交换机发送一回车符,可以避免telnet到交换机后常时间不发送信息导致telnet自动关闭。当Timer事件发生时,查找date.txt文件和week.txt文件中的信息,如果文件中存在某个设定时间和当前时间相同,则按照文件中该条信息修改子网的状态。下面给出了Timer事件的部分代码: paper51.com

  Dim xianzai As datetable '对日期进行设置

http://www.paper51.com

  xianzai.year = CInt(Format$(Now,"yyyy")) http://www.paper51.com

  xianzai.month = CInt(Format$(Now,"mm"))

内容来自论文无忧网 www.paper51.com

  xianzai.day = CInt(Format$(Now,"dd"))

copyright paper51.com

  xianzai.hour = CInt(Format$(Now,"h"))

内容来自www.paper51.com

  xianzai.minite = CInt(Format$(Now,"n")) http://www.paper51.com

  If FileLen(App.Path &"/date.txt") <> 0 Then

内容来自www.paper51.com

    Dim datet(100) As datetable

http://www.paper51.com

    i = 1 paper51.com

    Open App.Path &"/date.txt" For Input As #1 '读回所有数据 http://www.paper51.com

      Do While NotEOF(1) http://www.paper51.com

       Input #1, datet(i).year, datet(i).month, datet(i).day, datet(i).hour,datet(i).minite, datet(i).a, datet(i).b

http://www.paper51.com

        i =i + 1 内容来自www.paper51.com

      Loop 内容来自论文无忧网 www.paper51.com

    Close 1

内容来自论文无忧网 www.paper51.com

    For j = 1 To i - 1

paper51.com

      If xianzai.year= datet(j).year And xianzai.month = datet(j).month And xianzai.day =datet(j).day And xianzai.hour = datet(j).hour And xianzai.minite =datet(j).minite Then paper51.com

        ii =1 paper51.com

        OpenApp.Path & "/subnet.txt" For Input As #1 '读回子网信息

copyright paper51.com

         Do While Not EOF(1) 内容来自论文无忧网 www.paper51.com

           Input #1, netgates(ii).name, netgates(ii).gateway,netgates(ii).portnumber, netgates(ii).states copyright paper51.com

         ii = ii + 1

内容来自论文无忧网 www.paper51.com

         Loop

内容来自www.paper51.com

       Close 1 内容来自www.paper51.com

        Forjjj = 1 To ii - 1

copyright paper51.com

         If datet(j).a = netgates(jjj).name Then

内容来自www.paper51.com

           If datet(j).b <> netgates(jjj).states Then

内容来自www.paper51.com

             netgates(jjj).states = datet(j).b

内容来自论文无忧网 www.paper51.com

             Winsock1.SendData ("config t" & vbCrLf) 内容来自论文无忧网 www.paper51.com

             Select Case datet(j).b '修改该子网的状态。

paper51.com

               Case 0 内容来自www.paper51.com

                 Winsock1.SendData ("interface vlan 2" & vbCrLf)

内容来自www.paper51.com

                 Winsock1.SendData ("no ip access-group " &netgates(jjj).portnumber & " out" & vbCrLf)

http://www.paper51.com

                 Winsock1.SendData("exit" & vbCrLf) http://www.paper51.com

                 Winsock1.SendData ("interface vlan " &netgates(jjj).portnumber & vbCrLf)

paper51.com

                 Winsock1.SendData ("no ip access-group 2 in" & vbCrLf) http://www.paper51.com

               Case 1

http://www.paper51.com

                 Winsock1.SendData ("interface vlan 2" & vbCrLf)

http://www.paper51.com

                 Winsock1.SendData ("ip access-group " &netgates(jjj).portnumber & " out" & vbCrLf) 内容来自论文无忧网 www.paper51.com

                 Winsock1.SendData ("exit" & vbCrLf) http://www.paper51.com

                 Winsock1.SendData ("interface vlan " & netgates(jjj).portnumber& vbCrLf) 内容来自www.paper51.com

                 Winsock1.SendData ("no ip access-group 2 in" & vbCrLf)

copyright paper51.com

               Case 2 内容来自论文无忧网 www.paper51.com

                 Winsock1.SendData ("interface vlan " &netgates(jjj).portnumber & vbCrLf) 内容来自论文无忧网 www.paper51.com

                 Winsock1.SendData ("ip access-group 2 in" & vbCrLf) paper51.com

             End Select

copyright paper51.com

             Winsock1.SendData ("end" & vbCrLf)

http://www.paper51.com

             Open App.Path & "/subnet.txt" For Output As #1

内容来自论文无忧网 www.paper51.com

               Write #1, netgates(1).name, netgates(1).gateway, netgates(1).portnumber,netgates(1).states 内容来自www.paper51.com

             Close 1 copyright paper51.com

             For n = 2 To ii - 1

paper51.com

               Open App.Path & "/subnet.txt" For Append As #1

内容来自论文无忧网 www.paper51.com

                 Write #1, netgates(n).name, netgates(n).gateway, netgates(n).portnumber,netgates(n).states 内容来自www.paper51.com

                Close1 http://www.paper51.com

             Next n

内容来自www.paper51.com

             frmmain.cbosubname.ListIndex = 0 内容来自论文无忧网 www.paper51.com

             frmmain.labelgateway.Caption = netgates(1).gateway copyright paper51.com

             frmmain.Labelport.Caption = netgates(1).portnumber copyright paper51.com

             Select Case netgates(1).states 内容来自论文无忧网 www.paper51.com

               Case 0

http://www.paper51.com

                 frmmain.labelconnect.Caption = "公网" 内容来自www.paper51.com

               Case 1

paper51.com

                 frmmain.labelconnect.Caption = "校园网" 内容来自论文无忧网 www.paper51.com

               Case 2

内容来自论文无忧网 www.paper51.com

                 frmmain.labelconnect.Caption = "本网" copyright paper51.com

             End Select

内容来自论文无忧网 www.paper51.com

           End If

paper51.com

         End If http://www.paper51.com

        Nextjjj 内容来自www.paper51.com

      End If copyright paper51.com

    Next j paper51.com

  End If

http://www.paper51.com

------分隔线----------------------------
联系方式