Brug af AI afslører de svagheder, virksomheder allerede har opbygget gennem års cloud-transformation, nye SaaS-løsninger og fragmenterede sikkerhedssystemer.
Her er en løsning, MEN - den er rædselsfuld på grund af VB's manglende muligheder udi bit-manipulation. Hvad der sker er, at jeg konverterer proper_address (som SKAL være en long, evt fremstillet med CLng) til en hexadecimal streng, som sidenhen konverteres til de 4 decimale IP-adresse-tal 2 hexadecimale cifre ad gangen:
Function hexchr2num( chr ) if chr >= "0" and chr <= "9" then hexchr2num = asc(chr) - asc("0") else hexchr2num = asc(chr) - asc("A") + 10 end if End Function
Function long2ip( proper_address ) dim i dim str dim dot dim hexstr
str = "" dot = ""
hexstr = hex(proper_address) hexstr = left("00000000", 8-len(hexstr)) & hexstr for i = 0 to 3 str = str & dot & _ CStr(hexchr2num(mid(hexstr,i*2+1, 1)) * 16 + _ hexchr2num(mid(hexstr,i*2+2, 1))) dot = "." next long2ip = str End Function
function CStrIP(ByVal anNewIP) Dim lsResults ' Results To be returned Dim lnTemp ' Temporary value being parsed Dim lnIndex ' Position of number being parsed ' if pulling number from an Access Database, ' The variable Type "Long" ranges from -2147483648 To 2147483647 ' You will first need To add 2147483648 to the number to parse correctly. ' anNewIP = anNewIP + 2147483648 ' Parse highest numbers first For lnIndex = 3 To 0 Step -1
' Parse the current value For this position lnTemp = Int(anNewIP / (256 ^ lnIndex))
' Append the number To the final results delimited by a dot lsResults = lsResults & lnTemp & "."
' Remove the number that we just parsed anNewIP = anNewIP - (lnTemp * (256 ^ lnIndex))
Next
' Cut off last dot lsResults = Left(lsResults, Len(lsResults) - 1)
' Return the results CStrIP = lnResults
End function
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.