- Home
·
- Internet/HTML
·
- Verify a given port. This is good if the user enters a port, and you want to verify it before conne
Verify a given port. This is good if the user enters a port, and you want to verify it before conne
Verify a given port. This is good if the user enters a port, and you want to verify it before connecting, cutting back on errors.
Rate Verify a given port. This is good if the user enters a port, and you want to verify it before conne
(1(1 Vote))
'Put this in a module, or change "Public" to
'"Private" and put it in a form.
Trim(PortStr)
'If there's nothing in the box assume the
'user has cleared it and return no errors.
If Len(PortStr) = 0 Then
VerifyPort = False
Exit Function
End If
'Check to see if the string can be converted
'to an integer.
If IsNumeric(PortStr) = False Then
MsgBox "Error: Integer values only.", vbInformation, "Error!"
VerifyPort = False
Exit Function
End If
'IsNumeric doesn't search for commas, so check
'if the user entered a comma.
For i = 1 To Len(PortStr)
If InStr(i, PortStr, ",") Then
MsgBox "Error: Integer values only.", vbInformation, "Error!"
VerifyPort = False
Exit Function
End If
Next i
'If the port is or starts with a zero, return
'an error.
If Val(PortStr) = 0 Then
MsgBox "Error: Ports 1 - 65535 Only.", vbInformation, "Error!"
VerifyPort = False
Exit Function
End If
If Left(PortStr, 1) = "0" Then
MsgBox "Error: Ports 1 - 65535 Only.", vbInformation, "Error!"
VerifyPort = False
Exit Function
End If
'Check if the port exceeds the maximum range.
If Val(txtRemotePort.Text) > 65535 Then
MsgBox "Error: Ports 1 - 65535 only.", vbInformation, "Error!"
txtLocalPort.Text = "65535"
VerifyPort = False
Exit Function
End If
VerifyPort = True
End Function
Verify a given port. This is good if the user enters a port, and you want to verify it before conne Comments
No comments yet — be the first to post one!
Post a Comment