Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim a, b, c As Long
- Dim text, bin, Prevar As String
- Dim n, i, dec As Integer
- Private Sub Command1_Click()
- 'Prefix calculater
- For X = 1 To Text3.text
- Prevar = Prevar & "1"
- Next X
- For X = 1 To 32 - Text3.text
- Prevar = Prevar & "0"
- Next X
- n = 1
- For v = 0 To 3
- Text2(v).text = Mid(Prevar, n, 8)
- n = n + 8
- Next v
- Prevar = ""
- Call Command3_Click
- End Sub
- Private Sub Command2_Click()
- 'Dec to bin subnet mask
- For X = 0 To 3
- a = Val(Text1(X).text)
- Text2(X).text = ""
- If a = 1 Or a = 0 Then
- Text2(X).text = a
- Else
- Do Until c = 1
- b = a Mod 2
- c = Int(a / 2)
- a = c
- If b = 1 Then
- Text2(X).text = "1" & Text2(X).text
- ElseIf b = 0 Then
- Text2(X).text = "0" & Text2(X).text
- End If
- Loop
- c = 0
- Text2(X).text = "1" & Text2(X).text
- End If
- Text2(X) = Format(Text2(X), "00000000")
- Next
- End Sub
- Private Sub Command3_Click()
- 'Bin to Dec subnet mask
- For z = 0 To 3
- dec = 0
- bin = Text2(z).text
- i = Len(Text2(z).text) - 1
- For n = 1 To Len(Text2(z).text)
- dec = dec + Mid(bin, n, 1) * (2 ^ i)
- i = i - 1
- Next
- Text1(z).text = dec
- Next
- End Sub
- Private Sub Command4_Click()
- 'Dec to bin host
- For X = 0 To 3
- a = Val(Text4(X).text)
- Text5(X).text = ""
- If a = 1 Or a = 0 Then
- Text5(X).text = a
- Else
- Do Until c = 1
- b = a Mod 2
- c = Int(a / 2)
- a = c
- If b = 1 Then
- Text5(X).text = "1" & Text5(X).text
- ElseIf b = 0 Then
- Text5(X).text = "0" & Text5(X).text
- End If
- Loop
- c = 0
- Text5(X).text = "1" & Text5(X).text
- End If
- Text5(X) = Format(Text5(X), "00000000")
- Next
- Call NetworkID
- End Sub
- Private Sub Command5_Click()
- 'bin to dec host
- For z = 0 To 3
- dec = 0
- bin = Text5(z).text
- i = Len(Text5(z).text) - 1
- For n = 1 To Len(Text5(z).text)
- dec = dec + Mid(bin, n, 1) * (2 ^ i)
- i = i - 1
- Next
- Text4(z).text = dec
- Next
- End Sub
- Private Sub Command6_Click()
- 'clear textboxes i prefix
- For k = 0 To 3
- Text1(k).text = blank
- Text2(k).text = blank
- Text3.text = blank
- Next
- End Sub
- Private Sub Command7_Click()
- 'clear textboxes i host
- For k = 0 To 3
- Text4(k).text = blank
- Text5(k).text = blank
- Next
- End Sub
- Private Sub NetworkID()
- 'Kopire host oct 0 to 2 bin og dec
- For f = 0 To 2
- Text7(f).text = Text5(f).text
- Text6(f).text = Text4(f).text
- Text13(f).text = Text7(f).text
- 'Text12(f).text = Text6(f).text
- Next f
- 'Beregner bin network ID text7(3)
- For n = 1 To 8
- If Mid(Text2(3).text, n, 1) And Mid(Text5(3).text, n, 1) = 1 Then
- Text7(3).text = Text7(3).text & "1"
- Else
- Text7(3).text = Text7(3).text & "0"
- End If
- Next n
- 'Binรฆrt til Dec i networkID
- For z = 0 To 3
- dec = 0
- bin = Text7(z).text
- i = Len(Text7(z).text) - 1
- For n = 1 To Len(Text7(z).text)
- dec = dec + Mid(bin, n, 1) * (2 ^ i)
- i = i - 1
- Next
- Text6(z).text = dec
- Next
- 'first host
- For Y = 0 To 3
- Text8(Y).text = Text6(Y).text 'first host
- Text9(Y).text = Text7(Y).text 'First host
- Next
- Text8(3).text = Val(Text8(3).text) + 1 ' first host
- Text9(3).text = Val(Text9(3).text) + 1 ' first host
- 'Broadcast
- For n = 1 To 8
- If Mid(Text2(3), n, 1) = 1 Then
- Text13(3).text = Text13(3).text & Mid(Text7(3), n, 1)
- Else
- Text13(3).text = Text13(3).text & "1"
- End If
- Next n
- 'binรฆrt til dec i broadcast
- For z = 0 To 3
- dec = 0
- bin = Text13(z).text
- i = Len(Text13(z).text) - 1
- For n = 1 To Len(Text13(z).text)
- dec = dec + Mid(bin, n, 1) * (2 ^ i)
- i = i - 1
- Next
- Text12(z).text = dec
- Next
- 'last host
- For Y = 0 To 3
- Text10(Y).text = Text6(Y).text 'last host
- Text11(Y).text = Text7(Y).text 'last host
- Next
- Text10(3).text = Val(Text12(3).text) - 1 ' last host
- Text11(3).text = Val(Text13(3).text) - 1 ' last host
- 'antal host
- Text14.text = 2 ^ (32 - Text3.text) - 2
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement