Trasformare un IP in numero e viceversa [VB6][SC].txtTRSFORMARE UN IP IN NUMERO E VICEVERSA [VB6] Trasforma un ip in decim...
Upcoming SlideShare
Loading in …5
×

Trasformare un ip in numero e viceversa [vb6][sc]

316 views

Published on

Trasformare un IP in numero e viceversa [VB6][SC]

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
316
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Trasformare un ip in numero e viceversa [vb6][sc]

  1. 1. Trasformare un IP in numero e viceversa [VB6][SC].txtTRSFORMARE UN IP IN NUMERO E VICEVERSA [VB6] Trasforma un ip in decimalePublic Function ip2dec(ByVal a0 As Byte, a1 As Byte, a2 As Byte, a3 As Byte) As Double ip2dec = 2 ^ 24 * a3 + 2 ^ 16 * a2 + 2 ^ 8 * a1 + 2 ^ 0 * a0End Function Trasforma un decimale in ipPublic Function dec2ip(v As Double) As Byte() Dim b(3) As Byte b(0) = v - truncate(v / 256) * 256 v = truncate(v / 256) b(1) = v - truncate(v / 256) * 256 v = truncate(v / 256) b(2) = v - truncate(v / 256) * 256 v = truncate(v / 256) b(3) = v - truncate(v / 256) * 256 dec2ip = bEnd Function Elimina la parte decimale da un double. N.B. non è possibile farlo con clng() poiché genera un overflowPublic Function truncate(ByVal v As Double) As Double Dim s As String, idx As Integer, ret As Double s = Replace(CStr(v), ",", ".") idx = InStr(s, ".") If idx > 0 Then Prende solo la parte intera s = Left(s, idx - 1) End If ret = CDbl(s) truncate = sEnd Function 1agina p

×