论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP JSP .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 其他 代写论文

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

5.3 定时功能的实现

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

paper51.com

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

copyright paper51.com

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

  xianzai.year = CInt(Format$(Now,"yyyy"))

paper51.com

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

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

http://www.snowings.com

  xianzai.hour = CInt(Format$(Now,"h")) 内容来自www.snowings.com

  xianzai.minite = CInt(Format$(Now,"n")) paper51.com

  If FileLen(App.Path &"/date.txt") <> 0 Then 内容来自论文无忧网 www.snowings.com

    Dim datet(100) As datetable http://www.snowings.com

    i = 1 copyright paper51.com

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

      Do While NotEOF(1)

http://www.snowings.com

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

        i =i + 1 paper51.com

      Loop

paper51.com

    Close 1 http://www.snowings.com

    For j = 1 To i - 1 内容来自论文无忧网 www.snowings.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

http://www.snowings.com

        ii =1 http://www.snowings.com

        OpenApp.Path & "/subnet.txt" For Input As #1 '读回子网信息 内容来自www.snowings.com

         Do While Not EOF(1)

copyright paper51.com

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

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

         ii = ii + 1 http://www.snowings.com

         Loop

内容来自www.snowings.com

       Close 1 paper51.com

        Forjjj = 1 To ii - 1

paper51.com

         If datet(j).a = netgates(jjj).name Then 内容来自论文无忧网 www.snowings.com

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

paper51.com

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

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

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

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

内容来自www.snowings.com

               Case 0 内容来自论文无忧网 www.snowings.com

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

copyright paper51.com

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

http://www.snowings.com

                 Winsock1.SendData("exit" & vbCrLf)

http://www.snowings.com

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

paper51.com

                 Winsock1.SendData ("no ip access-group 2 in" & vbCrLf) 内容来自论文无忧网 www.snowings.com

               Case 1

paper51.com

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

paper51.com

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

paper51.com

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

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

内容来自www.snowings.com

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

内容来自www.snowings.com

               Case 2 paper51.com

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

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

             End Select 内容来自www.snowings.com

             Winsock1.SendData ("end" & vbCrLf)

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

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

copyright paper51.com

               Write #1, netgates(1).name, netgates(1).gateway, netgates(1).portnumber,netgates(1).states 内容来自论文无忧网 www.snowings.com

             Close 1 http://www.snowings.com

             For n = 2 To ii - 1 内容来自www.snowings.com

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

copyright paper51.com

                 Write #1, netgates(n).name, netgates(n).gateway, netgates(n).portnumber,netgates(n).states

paper51.com

                Close1

内容来自www.snowings.com

             Next n

http://www.snowings.com

             frmmain.cbosubname.ListIndex = 0 内容来自www.snowings.com

             frmmain.labelgateway.Caption = netgates(1).gateway http://www.snowings.com

             frmmain.Labelport.Caption = netgates(1).portnumber

copyright paper51.com

             Select Case netgates(1).states copyright paper51.com

               Case 0 http://www.snowings.com

                 frmmain.labelconnect.Caption = "公网"

paper51.com

               Case 1 copyright paper51.com

                 frmmain.labelconnect.Caption = "校园网" http://www.snowings.com

               Case 2 http://www.snowings.com

                 frmmain.labelconnect.Caption = "本网" 内容来自www.snowings.com

             End Select paper51.com

           End If

内容来自www.snowings.com

         End If

内容来自www.snowings.com

        Nextjjj copyright paper51.com

      End If

paper51.com

    Next j paper51.com

  End If

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

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