0

誰かがこれを vb.net 2010 コードに変換するのを手伝ってくれますか? 私はテキストボックス1を持つウィンドウを持っています.私はこのコードbt cldnt図を見つけました.hoはvb.net 2010でそれを書くことができます.

Imports System.Diagnostics

Module Module1
    Sub Main()
        Dim pc As New PerformanceCounterCategory("Network Interface")
        Dim instance As String = pc.GetInstanceNames(0)
        Dim bs As New PerformanceCounter("Network Interface", "Bytes Sent/sec", instance)
        Dim br As New PerformanceCounter("Network Interface", "Bytes Received/sec", instance)
        Console.WriteLine("Monitoring " & instance)
        Do
            Dim kbSent As Integer = bs.NextValue() / 1024
            Dim kbReceived As Integer = br.NextValue() / 1024
            Console.WriteLine(String.Format("Bytes Sent {0}k Bytes Received {1}k", kbSent, kbReceived))
            Threading.Thread.Sleep(1000)
        Loop
    End Sub
End Module
4

1 に答える 1

0

コンソールアプリのように見えますが、

あなたが苦労しているかもしれないのは、データをテキストボックスに入れる方法ですか? あなたのサンプルでは、​​コンソールウィンドウに書き込まれていました。

これらの行を変更するだけで問題ありません。

Console.WriteLine("Monitoring " & instance)

上記を次のように変更します。

Texbox1.text = "Monitoring " & instance & vbcrlf

この行も変更します

Console.WriteLine(String.Format("Bytes Sent {0}k Bytes Received {1}k", kbSent, kbReceived))

次のように変更します。

Textbox1.Text = Textbox1.Text & String.Format("Bytes Sent {0}k, Bytes Received {1}k", kbSent, kbReceived)
于 2013-04-26T18:14:28.193 に答える