IP to digital conversion

xiaoxiao2021-03-06  68

Usually, in the programming process of the database, you need to record some IP addresses, which is originally saved in the form of direct and IP addresses (xxx.xxx.xxx.xxx), that is, in the database, it is clear, and is a string, compared space. One day, my colleague made me help him into IP addresses. The database is Sygate (a shared Internet software) is used to record Internet records, I opened the database, I just didn't have anything. Because you have no research on this, let's find it online, look at there is no relevant information, um, good, now the network basically wants the information you can find, I am looking for an article, Or more appropriately is a text description, introducing its algorithms; since there is already a clue, then start with code. The 'conversion process is as follows:' 1, get IP, such as: 192.168.0.1'2, then reverse the IP sequence: 1.0.168.192'3, divide IP into four parts, transfer to 16 yuan, the number of bits is insufficient, Add 0 left, the conversion is completed, the conversion is: 01.00.a8.c0'4, remove all ".", The result is: 100A8c0'5, then transfer it to decimal: 16820416

'// ip to digital conversion public function iptonumber (byval strign as string) AS STRING DIM STRTEMP AS STRING DIM STRIP () AS STRING DIM STROUTPUT AS STRING DIM I AS INTEGER ON ERROR GOTO Locaterr' // divide IP into 4 parts Strip = split (Strvalue, ".") '// This is to poured IP, namely: 192.168.0.1 = 1.0.168.192 for i = 3 to 0 Step -1 strTemp = HEX $ (Strip (i))' // Trove NEXT IPTONUTPUT & STRTEMP next iptonumber = cstr (TRIM ("& h")) EXIT (TRIM ("& H" & stroutput) FunctionLocaterr: Err.clear iptonumber = "" End Function

转载请注明原文地址:https://www.9cbs.com/read-110055.html

New Post(0)