Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. having problems (Public Shared Sub ShowTcpStatistics) Statement cannot within method body. End of method assumed// which is affecting my txtbox.Text

having problems (Public Shared Sub ShowTcpStatistics) Statement cannot within method body. End of method assumed// which is affecting my txtbox.Text

Scheduled Pinned Locked Moved Visual Basic
csharpannouncement
15 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dave Kreskowiak

    I think the cause of the error is really quite obvious. You didn't terminate your Protected Sub Button4_Click() method with an End Sub before you started with Public Shared Sub ShowTcpStatistics().

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
         2006, 2007, 2008
    But no longer in 2009...

    T Offline
    T Offline
    that_dude_tj
    wrote on last edited by
    #4

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click ShowTcpStatistics(txtB.Text) End Sub Public Shared Sub ShowTcpStatistics(ByVal version As NetworkInterfaceComponent) Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties() Dim tcpstat As TcpStatistics = Nothing txtbox.Text = "" For Each tcp As TcpStatistics In tcpstat txtbox = tcp.ToString() Next Select Case version Case (NetworkInterfaceComponent.IPv4) tcpstat = properties.GetTcpIPv4Statistics() txtbox.Text("TCP/IPv4 Statistics:") Exit Select Case (NetworkInterfaceComponent.IPv6) tcpstat = properties.GetTcpIPv6Statistics() txtbox.Text("TCP/IPv6 Statistics:") Exit Select Case Else Throw (New ArgumentException("version")) ' break; End Select txtbox.Text(" Minimum Transmission Timeout............. : {0}", tcpstat.MinimumTransmissionTimeout) txtbox.Text(" Maximum Transmission Timeout............. : {0}", tcpstat.MaximumTransmissionTimeout) txtbox.Text(" Connection Data:") txtbox.Text(" Current ............................ : {0}", tcpstat.CurrentConnections) txtbox.Text(" Cumulative .......................... : {0}", tcpstat.CumulativeConnections) txtbox.Text(" Initiated ........................... : {0}", tcpstat.ConnectionsInitiated) txtbox.Text(" Accepted ............................ : {0}", tcpstat.ConnectionsAccepted) txtbox.Text(" Failed Attempts ..................... : {0}", tcpstat.FailedConnectionAttempts) txtbox.Text(" Reset ............................... : {0}", tcpstat.ResetConnections) txtbox.Text("") txtbox.Text(" Segment Data:") txtbox.Text(" Received ........................... : {0}", tcpstat.SegmentsReceived) txtbox.Text(" Sent ................................ : {0}", tcpstat.SegmentsSent) txtbox.Text(" Retransmitted ....................... : {0}", tcpstat.SegmentsResent) txtbox.Text("") End Sub

    C D 2 Replies Last reply
    0
    • T that_dude_tj

      Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click ShowTcpStatistics(txtB.Text) End Sub Public Shared Sub ShowTcpStatistics(ByVal version As NetworkInterfaceComponent) Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties() Dim tcpstat As TcpStatistics = Nothing txtbox.Text = "" For Each tcp As TcpStatistics In tcpstat txtbox = tcp.ToString() Next Select Case version Case (NetworkInterfaceComponent.IPv4) tcpstat = properties.GetTcpIPv4Statistics() txtbox.Text("TCP/IPv4 Statistics:") Exit Select Case (NetworkInterfaceComponent.IPv6) tcpstat = properties.GetTcpIPv6Statistics() txtbox.Text("TCP/IPv6 Statistics:") Exit Select Case Else Throw (New ArgumentException("version")) ' break; End Select txtbox.Text(" Minimum Transmission Timeout............. : {0}", tcpstat.MinimumTransmissionTimeout) txtbox.Text(" Maximum Transmission Timeout............. : {0}", tcpstat.MaximumTransmissionTimeout) txtbox.Text(" Connection Data:") txtbox.Text(" Current ............................ : {0}", tcpstat.CurrentConnections) txtbox.Text(" Cumulative .......................... : {0}", tcpstat.CumulativeConnections) txtbox.Text(" Initiated ........................... : {0}", tcpstat.ConnectionsInitiated) txtbox.Text(" Accepted ............................ : {0}", tcpstat.ConnectionsAccepted) txtbox.Text(" Failed Attempts ..................... : {0}", tcpstat.FailedConnectionAttempts) txtbox.Text(" Reset ............................... : {0}", tcpstat.ResetConnections) txtbox.Text("") txtbox.Text(" Segment Data:") txtbox.Text(" Received ........................... : {0}", tcpstat.SegmentsReceived) txtbox.Text(" Sent ................................ : {0}", tcpstat.SegmentsSent) txtbox.Text(" Retransmitted ....................... : {0}", tcpstat.SegmentsResent) txtbox.Text("") End Sub

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #5

      that_dude_tj wrote:

      txtbox.Text("TCP/IPv4 Statistics:")

      Does this work ? What does it do ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      N T 2 Replies Last reply
      0
      • C Christian Graus

        that_dude_tj wrote:

        txtbox.Text("TCP/IPv4 Statistics:")

        Does this work ? What does it do ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        N Offline
        N Offline
        nlarson11
        wrote on last edited by
        #6

        not sure why he wrote that. it does not work. text has an overload but it only extracts the character position at the given number textbox1.text(3)

        'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

        C 1 Reply Last reply
        0
        • N nlarson11

          not sure why he wrote that. it does not work. text has an overload but it only extracts the character position at the given number textbox1.text(3)

          'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #7

          OK, that's interesting. It's a property AND a method ? I didn't know that. Either way, his response looked to me like a further question, but no question was present, so I was trying to guess the problem

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          N 0 2 Replies Last reply
          0
          • T that_dude_tj

            Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click ShowTcpStatistics(txtB.Text) End Sub Public Shared Sub ShowTcpStatistics(ByVal version As NetworkInterfaceComponent) Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties() Dim tcpstat As TcpStatistics = Nothing txtbox.Text = "" For Each tcp As TcpStatistics In tcpstat txtbox = tcp.ToString() Next Select Case version Case (NetworkInterfaceComponent.IPv4) tcpstat = properties.GetTcpIPv4Statistics() txtbox.Text("TCP/IPv4 Statistics:") Exit Select Case (NetworkInterfaceComponent.IPv6) tcpstat = properties.GetTcpIPv6Statistics() txtbox.Text("TCP/IPv6 Statistics:") Exit Select Case Else Throw (New ArgumentException("version")) ' break; End Select txtbox.Text(" Minimum Transmission Timeout............. : {0}", tcpstat.MinimumTransmissionTimeout) txtbox.Text(" Maximum Transmission Timeout............. : {0}", tcpstat.MaximumTransmissionTimeout) txtbox.Text(" Connection Data:") txtbox.Text(" Current ............................ : {0}", tcpstat.CurrentConnections) txtbox.Text(" Cumulative .......................... : {0}", tcpstat.CumulativeConnections) txtbox.Text(" Initiated ........................... : {0}", tcpstat.ConnectionsInitiated) txtbox.Text(" Accepted ............................ : {0}", tcpstat.ConnectionsAccepted) txtbox.Text(" Failed Attempts ..................... : {0}", tcpstat.FailedConnectionAttempts) txtbox.Text(" Reset ............................... : {0}", tcpstat.ResetConnections) txtbox.Text("") txtbox.Text(" Segment Data:") txtbox.Text(" Received ........................... : {0}", tcpstat.SegmentsReceived) txtbox.Text(" Sent ................................ : {0}", tcpstat.SegmentsSent) txtbox.Text(" Retransmitted ....................... : {0}", tcpstat.SegmentsResent) txtbox.Text("") End Sub

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #8

            So what's this?? You didn't ask a question and I'm not inclined to just start throwing test apps together to guess what you want out of this...

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008
            But no longer in 2009...

            T 1 Reply Last reply
            0
            • D Dave Kreskowiak

              So what's this?? You didn't ask a question and I'm not inclined to just start throwing test apps together to guess what you want out of this...

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008
              But no longer in 2009...

              T Offline
              T Offline
              that_dude_tj
              wrote on last edited by
              #9

              lol my question is then i would be. that im unable to display the tcp statistics in my text box

              C D 2 Replies Last reply
              0
              • T that_dude_tj

                lol my question is then i would be. that im unable to display the tcp statistics in my text box

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #10

                I responded four hours ago to try to keep helping you, but you didn't even reply ? You need to read a pretty basic VB.NET book. You seem to be making code up instead of knowing what you're doing. The best way to do what you want, is use a StringBuilder to build the message, as it's multiline from what I can tell, and then set that text to the Text property.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                T 1 Reply Last reply
                0
                • C Christian Graus

                  that_dude_tj wrote:

                  txtbox.Text("TCP/IPv4 Statistics:")

                  Does this work ? What does it do ?

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  T Offline
                  T Offline
                  that_dude_tj
                  wrote on last edited by
                  #11

                  No not working yet it suppose to display Internet Protocol version 4 (TCP/IPv4) statistical data for the local computer to my textbox name txtbox. i used this in the ping and it worked fine Dim ping As Ping = New Ping() Dim pingreply As PingReply = ping.Send(txtHost.Text) txtPing.Text &= "Address: " & pingreply.Address.ToString() & Constants.vbCr txtPing.Text &= "Roundtrip Time: " & pingreply.RoundtripTime & Constants.vbCr txtPing.Text &= "TTL (Time to Live): " & pingreply.Options.Ttl & Constants.vbCr txtPing.Text &= "Buffer Size: " & pingreply.Buffer.Length.ToString() & Constants.vbCr

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    I responded four hours ago to try to keep helping you, but you didn't even reply ? You need to read a pretty basic VB.NET book. You seem to be making code up instead of knowing what you're doing. The best way to do what you want, is use a StringBuilder to build the message, as it's multiline from what I can tell, and then set that text to the Text property.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    T Offline
                    T Offline
                    that_dude_tj
                    wrote on last edited by
                    #12

                    Thanks ill get to reading

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      OK, that's interesting. It's a property AND a method ? I didn't know that. Either way, his response looked to me like a further question, but no question was present, so I was trying to guess the problem

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      N Offline
                      N Offline
                      nlarson11
                      wrote on last edited by
                      #13

                      I just tried it. It probably is 2 properties that are overloaded 'a' = text for the example

                      Public ReadOnly Property a(ByVal idx As Int16) As String
                          Get
                              'extracts character at position
                          End Get
                      End Property
                      
                      Public Property a() As String
                          Get
                                 
                          End Get
                          Set(ByVal value As String)
                      
                          End Set
                      End Property
                      

                      'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

                      1 Reply Last reply
                      0
                      • C Christian Graus

                        OK, that's interesting. It's a property AND a method ? I didn't know that. Either way, his response looked to me like a further question, but no question was present, so I was trying to guess the problem

                        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                        0 Offline
                        0 Offline
                        0x3c0
                        wrote on last edited by
                        #14

                        I'm not certain, but I think it's just a property. It returns String, and the String object has a built in indexer. Just like you could have a List(Of List(Of Integer)), and use lst(0)(1) and get an Integer back

                        Between the idea And the reality Between the motion And the act Falls the Shadow

                        1 Reply Last reply
                        0
                        • T that_dude_tj

                          lol my question is then i would be. that im unable to display the tcp statistics in my text box

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #15

                          Your textbox lines are a bit funny. You seem to think there is a .Text method on it, but .Text is actually a property. Since you keep replacing the .Text property with a new line of text, the last line you supply is blank, so nothing will show up in the textbox. Serisouly, pickup a beginners book on VB.NET. You're missing some really basic concepts that we really can't describe to you in forum posts.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                               2006, 2007, 2008
                          But no longer in 2009...

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups