Jump to content


Check out our Community Blogs

blindtrevor

Member Since 16 Sep 2010
Offline Last Active Sep 23 2010 01:12 AM
-----

Posts I've Made

In Topic: How to create a Bandwidth Monitor

20 September 2010 - 08:13 AM

I've found an even better way of doing this - less glitchy and true .NET:

Imports System.Net.NetworkInformation
Then replace the whole objProcess bit with this:
Try
            Dim netInterface As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces
            For Each net As NetworkInterface In netInterface
                Dim statistics As IPv4InterfaceStatistics = net.GetIPv4Statistics
                If net.Name <> "MS TCP Loopback interface" Then
                    If net.OperationalStatus = 1 Then
                        DLoad = statistics.BytesReceived
                        ULoad = statistics.BytesSent
                    End If
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, ex.InnerException)
        End Try

In Topic: How do I convert the result of a msgbox to a textbox

17 September 2010 - 05:45 AM

Or:
Function roundBytes(ByVal bytes As String)
        If bytes > 1073741824 Then
            Return Round(bytes / 1073741824, 2) & " GB"
        ElseIf bytes > 1048576 Then
            Return Round(bytes / 1048576, 2) & " MB"
        ElseIf bytes > 1024 Then
            Return Round(bytes / 1024, 2) & " KB"
        Else
            Return bytes & " bytes"
        End If
    End Function

Make sure you add
Imports System.Math
at the top :)

In Topic: Reading a text file and saving to settings.

17 September 2010 - 05:42 AM

Hmmm... actually - this will just save each line to Setting1... Hmmmm?

How about domething like this...?

Imports System.IO

Public Class Form1


Dim FileReader As StreamReader
Dim fileLocation As String = "c:\text.txt"


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     If My.Computer.FileSystem.FileExists(fileLocation) Then
            FileReader = New StreamReader(fileLocation)
            Dim strLine As String
            Do
                strLine = FileReader.ReadLine
                If strLine <> Nothing Then
                    My.Settings.Setting1 = strLine
                    My.Settings.Save()
                End If
            Loop While strLine <> Nothing
            FileReader.Close()
        End If
End Sub
End Class


In Topic: Reading a text file and saving to settings.

17 September 2010 - 05:39 AM

How about domething like this...?

Imports System.IO

Public Class Form1


Dim FileReader As StreamReader
Dim fileLocation As String = "c:\text.txt"


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     If My.Computer.FileSystem.FileExists(fileLocation) Then
            FileReader = New StreamReader(fileLocation)
            Dim strLine As String
            Do
                strLine = FileReader.ReadLine
                If strLine <> Nothing Then
                    My.Settings.Setting1 = strLine
                    My.Settings.Save()
                End If
            Loop While strLine <> Nothing
            FileReader.Close()
        End If
End Sub
End Class

In Topic: [Help]Save value in textbox?

17 September 2010 - 05:26 AM

You can savve settings like this inside the EXE.

Try taking a look at my.settings

You need to go into "My Project" (in the sollution explorer window) and then click on the settings tab to set up all your different settings.

Then you can say something like:
for example, if you created a new setting called strTextBox...
My.Settings.strTextBox = TextBox1.text
My.Settings.Save
Then in the form.load section you can put:
TextBox1.text = My.Settings.strTextBox

there's no need to put things in the registry if you can help it :)

Any probelms, give me a shout :)


Andrew

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download