I have written a program in VB.NET, but when I debug it i get a bluescreen. It's a little confusing, because when I run my program on another computer it runs without problems and even better ( some feautures which didn't work on my computer work on other computers ).
I have a laptop with win 7 64-bit i7 2630QM 4Gb RAM nvidea 540m vidcard
My code:
Imports System.Net
Imports System.Net.Sockets
Public Class frmPcToolkit
Dim host As String
Public Function scanPorts(ByVal port As Integer, Optional ByVal sleepTime As Integer = 500) As Boolean
Dim client As New Net.Sockets.TcpClient
host = txtHost.Text
If pingToHost(host) = True Then
Try
client.BeginConnect(host, port, Nothing, Nothing)
For i = 0 To sleepTime
Threading.Thread.Sleep(1)
If client.Connected = True Then
Return True
End If
Next
client.Close()
Return False
Catch ex As Exception
client.Close()
Return False
End Try
Else
Call errorHandler()
Exit Function 'Hier moet de code stoppen dus een return is niet nodig!'
End If
End Function
Private Sub btnStartScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartScan.Click
Dim toPort As Integer
Dim fromPort As Integer
Try
toPort = CType(txtToPort.Text, Integer)
fromPort = CType(txtFromPort.Text, Integer)
Catch
Call errorHandler()
Exit Sub
End Try
Dim portStatus As Boolean
Dim aantalPorts As Integer
Dim aantalOpenPorts As Integer
aantalPorts = toPort - fromPort
If fromPort > 65536 Or fromPort < 1 Then
MsgBox("There is no such port in the system, please enter a valid one")
ElseIf fromPort = 65535 And toPort = 65535 Then
aantalPorts = 1
lstPorts.Items.Add("Port: 65535 " & scanPorts(65535, Nothing))
portStatus = scanPorts(65535, Nothing)
If portStatus = True Then
lstOpenPorts.Items.Add("Port: 65535" & portStatus)
End If
Else
lstPorts.Items.Clear()
lstOpenPorts.Items.Clear()
For i = fromPort To toPort
lstPorts.Items.Add("Port: " & i & " " & scanPorts(i, Nothing))
Next
For j = fromPort To toPort
portStatus = scanPorts(j, Nothing)
If portStatus = True Then
lstOpenPorts.Items.Add("Port: " & j & " " & portStatus)
End If
Next
aantalOpenPorts = lstOpenPorts.Items.Count
txtOpenPorts.Text = aantalOpenPorts
txtPortsCount.Text = aantalPorts
End If
End Sub
Private Sub lstPorts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstPorts.SelectedIndexChanged
Dim lstPort(0 To 1) As String
Dim selectedPort As String = lstPorts.SelectedItem
Dim selectedPortStatus As Boolean
lstPort = Split(selectedPort, " ")
txtPort.Text = lstPort(1)
selectedPortStatus = scanPorts(lstPort(1), Nothing)
If selectedPortStatus = False Then
txtPortStatus.Text = "Closed"
Else
txtPortStatus.Text = "Open"
End If
End Sub
Private Sub lstOpenPorts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstOpenPorts.SelectedIndexChanged
Dim lstOpenPort(0 To 1) As String
Dim selectedPort As String = lstOpenPorts.SelectedItem
lstOpenPort = Split(selectedPort, " ")
txtPort.Text = lstOpenPort(1)
txtPortStatus.Text = "Open"
End Sub
Private Sub txtFromPort_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFromPort.Click
txtFromPort.Text = ""
End Sub
Private Sub txtToPort_TClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtToPort.Click
txtToPort.Text = ""
End Sub
Private Sub frmPcToolkit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim networkConnectionStatus As Boolean
networkConnectionStatus = My.Computer.Network.IsAvailable
If networkConnectionStatus = True Then
txtnetworkConnectionStatus.Text = "Available"
ElseIf networkConnectionStatus = False Then
txtnetworkConnectionStatus.Text = "Not available"
End If
If pingToHost("www.google.com") = True Then
txtInternetConnectivity.Text = "Available"
ElseIf pingToHost("www.google.com") = False Then
txtInternetConnectivity.Text = "Not available"
MsgBox(pingToHost("www.google.com"))
End If
tslblNow.Text = Now
End Sub
Private Sub tmrNow_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrNow.Tick
Dim networkConnectionStatus As Boolean
networkConnectionStatus = My.Computer.Network.IsAvailable
If networkConnectionStatus = True Then
txtnetworkConnectionStatus.Text = "Available"
ElseIf networkConnectionStatus = False Then
txtnetworkConnectionStatus.Text = "Not available"
End If
tslblNow.Text = Now
End Sub
Private Sub btnPingToHost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPingToHost.Click
If pingToHost("www.google.com") = True Then
txtInternetConnectivity.Text = "Available"
ElseIf pingToHost("www.google.com") = False Then
txtInternetConnectivity.Text = "Not available"
End If
End Sub
Public Function pingToHost(ByVal ipHost As String) As Boolean
Try
My.Computer.Network.Ping(ipHost)
Return True
Catch
Return False
End Try
Return False
End Function
Public Function convertHostToIp(ByVal hostToConvert As String) As IPHostEntry
Dim ip As IPHostEntry
Try
ip = Dns.Resolve(hostToConvert)
Return ip
Catch
MsgBox("The hosttype was incorrect, please try again")
Return Nothing
Exit Function
End Try
End Function
Private Sub btnConvertHostToIp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvertHostToIp.Click
Dim conversionHost As String = txtHostToConvert.Text
Dim ip As IPHostEntry
Try
ip = convertHostToIp(conversionHost)
For Each adr As IPAddress In ip.AddressList
txtIpFromConversion.Text = adr.ToString
Next
Catch
MsgBox("An error has occured, please try again")
End Try
End Sub
Private Sub btnConverteerBinary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConverteerBinary.Click
Dim binaryInput As String
Dim hexaInput As String
binaryInput = txtBinaryInput.Text
hexaInput = txtConvertToHexaInput.Text
End Sub
Public Function errorHandler()
MsgBox("Er is onverwacht een fout opgetreden, gelieve het nog eens te proberen")
Return Nothing
End Function
End Class
I don't know where to look for the problem
corrections are welcome ( as well for my English :) )
Thx a lot!


Sign In
Create Account


Back to top









