展開輸出IP位址段

2021-04-16 02:32:38 字數 1446 閱讀 4539

用vb6展開輸出ip位址段

例如: 192.168.0.245-192.168.1.15 之間的各個ip位址

option explicit

private sub command1_click()

const max_range as long = 1000'最大生成的ip數,防止系統停止響應

dim sbeginip as string

dim sendip as string

sbeginip = "192.168.0.250"

sendip = "192.168.1.10"

dim i as long

dim lip as long

dim sip as string

lip = clng("&h" & dotip2hex(sbeginip))

sip = hex2dotip(hex(lip))

while sip <> sendip and i < max_range

print sip '列印點分ip字串

i = i + 1

lip = lip + 1

sip = hex2dotip(hex(lip))

wend

end sub

'點分ip字串轉換為十六進製制串

private function dotip2hex(byref sip as string) as string

dim shex as string

dim ash as variant

ash = split(sip, ".")

dim i as long

for i = 0 to 3

dim h as string

h = hex(ash(i))

shex = shex & iif(len(h) < 2, "0" & h, h)

next

dotip2hex = shex

end function

'十六進製制串轉換為點分ip字串

private function hex2dotip(byref sip as string) as string

dim shex as string

dim ash(3) as string

ash(0) = mid(sip, 1, 2)

ash(1) = mid(sip, 3, 2)

ash(2) = mid(sip, 5, 2)

ash(3) = mid(sip, 7, 2)

dim i as long

for i = 0 to 3

dim d as long

d = clng("&h" & ash(i))

shex = shex & "." & d

next

hex2dotip = mid(shex, 2)

end function

C 輸出IP位址段內的合法位址

近半年的intel實習生活快要結束了.馬上要找工作了,這段時間打算把以前的知識複習複習,順便在這裡記錄一下.這是當時去intel面試的時候,面試官問的一道題.當時因為時間關係,只讓我提供乙個思路,並沒有寫出具體實現過程.下面把實現過程寫上.主要是把ip位址轉換成整數,這樣比擷取ip位址每一段內的值出...

python IPy 匹配ip位址段

在ip位址規劃中,涉及到計算大量的ip位址,包括網段 網路掩碼 廣播位址 子網數 ip型別等 別擔心,ipy模組拯救你。ipy模組可以很好的輔助我們高效的完成ip的規劃工作。wget no check certificate tar zxvf ipy 0.81.tar.gz cd ipy 0.81 ...

私有IP位址段簡析

在現在的網路中,ip位址分為公網ip和私有ip位址。公網ip是在internet使用的ip位址,而私有ip位址是在區域網中使用的ip位址。私有ip位址是一段保留的ip位址。只是使用在區域網中,在internet上是不使用的。由於目前使用的ip v4協議的限制,現在ip位址的數量是有限的。不能為網中的...