🔔 Çevrimdışı bildirim almak ister misiniz?
Bir konuya etiketlendiğinizde, özel mesaj aldığınızda, bir mesajınız alıntılandığında forumda olmasanız bile anlık bildirim almak için lütfen izni verin.
PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
'Projenize 1 adet metin kutusu ve bir adet buton ekleyin
Public Function Valid_IP(IP As String) As Boolean Dim i As Integer Dim dot_count As Integer Dim test_octet As String Dim byte_check IP = Trim$(IP)
' make sure the IP long enough before ' continuing If Len(IP) < 8 Then Valid_IP = False 'Show Message MsgBox IP & " is Invalid", , "IP Validator" Exit Function End If
i = 1 dot_count = 0 For i = 1 To Len(IP) If Mid$(IP, i, 1) = "." Then ' increment the dot count and ' clear the test octet variable dot_count = dot_count + 1 test_octet = "" If i = Len(IP) Then ' we've ended with a dot ' this is not good Valid_IP = False 'Show Message MsgBox IP & " is Invalid", , "IP Validator" Exit Function End If Else test_octet = test_octet & Mid$(IP, i, 1) On Error Resume Next byte_check = CByte(test_octet) If (Err) Then ' either the value is not numeric ' or exceeds the range of the byte ' data type. Valid_IP = False Exit Function End If End If Next i ' so far, so good ' did we get the correct number of dots? If dot_count <> 3 Then Valid_IP = False Exit Function End If ' we have a valid IP format! Valid_IP = True 'Show Message MsgBox IP & " is Valid", , "IP Validator"
End Function
Private Sub Command1_Click() If Len(Text1) = 0 Then MsgBox "Please type an IP Address in the textbox.", , "IP Validator" Else 'Call the Function Valid_IP Text1 End If End Sub