I have the following code to check ports on my network. The scan is very slow, is there any way to optimize? The program evokes a timer on button click. Here is the code for the timer with interval set to (500ms). Sorry if my code is incorrectly written, just coding for fun, any input is appreciated!

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If begport <= endport Then
Dim Range As TcpClient = New TcpClient("", Label7.Text)
If Range.Connected = True Then
ListBox2.Items.Add(Label7.Text & " is Open")
ListBox2.ForeColor = Color.Red
Label7.Text += 1
End If
Catch ex As Exception
ListBox1.Items.Add(Label7.Text & " is Closed")
ListBox1.ForeColor = Color.Green
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Label7.Text += 1
End Try
Timer1.Enabled = False
MaskedTextBox1.Enabled = True
MaskedTextBox2.Enabled = True
Button1.Text = "Start Scan"
Button2.Text = "Stop Scan"
Button1.Enabled = True
Button2.Enabled = False
End If
End Sub