Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,316 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,093 people online right now. Registration is fast and FREE... Join Now!




ip calc

 
Reply to this topicStart new topic

ip calc

Najib
post 21 Feb, 2008 - 05:14 AM
Post #1


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 2

CODE

Private Sub Combo1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Combo3_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Combo4_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Combo4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""

End Sub

Private Sub Command2_Click()
'Dim ip1, ip2, ip3, ip4 As Integer
'Dim net_incr As Integer
'If ip2 <> 255 Then
'net_incr = 256 - ip2

'Text5.Text = Text1.Text + "." + CStr(net_incr) + "0" + "." + "0"
'ElseIf ip3 <> 255 Then
'net_incr = 256 - ip3
'Text6.Text = Text1.Text + "." + Text2.Text + CStr(net_incr) + "0" + "0"
'ElseIf ip4 <> 255 Then
    'Class A
'If Val(Text1.Text) <= 126 Then Text5.Text = Val(Text1.Text)
'If Val(Text1.Text) <= 126 Then Text8.Text = "0"
'If Val(Text1.Text) <= 126 Then Text9.Text = "0"
'If Val(Text1.Text) <= 126 Then Text10.Text = "0"
If Val(Text1.Text) <= 126 Then
Text5.Text = Val(Text1.Text)
Text8.Text = "0"
Text9.Text = "0"
Text10.Text = "0"
End If
    'Class B
'If Val(Text1.Text) >= 127 Then Text5.Text = Val(Text1.Text)
'If Val(Text2.Text) <= 255 Then Text8.Text = Val(Text2.Text)
'If Val(Text1.Text) <= 127 Then Text8.Text = "0"
'If Val(Text1.Text) >= 127 Then Text9.Text = "0"
'If Val(Text1.Text) >= 127 Then Text10.Text = "0"
If Val(Text1.Text) >= 127 Then
Text5.Text = Val(Text1.Text)
Text8.Text = Val(Text2.Text)
Text9.Text = "0"
Text10.Text = "0"
End If
    'class c
If Val(Text1.Text) >= 192 Then
Text5.Text = Val(Text1.Text)
Text8.Text = Val(Text2.Text)
Text9.Text = Val(Text3.Text)
Text10.Text = "0"
End If

'If Val(Text1.Text) >= 1 Then Text5.Text = Val(Text1.Text)
'If Val(Text2.Text) <= 255 Then Text8.Text = Val(Text2.Text)
'If Val(Text1.Text) <= 127 Then Text8.Text = "0"
'If Val(Text1.Text) >= 127 Then Text9.Text = "0"
'If Val(Text1.Text) >= 127 Then Text10.Text = "0"
'else if val(text)
'End If
        'broadcast addr 4 class a
If Val(Text1.Text) <= 126 Then
Text6.Text = Val(Text1.Text)
Text11.Text = "255"
Text12.Text = "255"
Text13.Text = "255"
End If
'broadcast addr 4 class b
If Val(Text1.Text) >= 127 Then
Text6.Text = Val(Text1.Text)
Text11.Text = Val(Text2.Text)
Text12.Text = "255"
Text13.Text = "255"
End If
'broadcast addr 4 class c
If Val(Text1.Text) >= 192 Then
Text6.Text = Val(Text1.Text)
Text11.Text = Val(Text2.Text)
Text12.Text = Val(Text3.Text)
Text13.Text = "255"
End If
        ' no of possile ntwk id class A
If Val(Text1.Text) <= 126 Then
Text14.Text = 2 ^ 7 - 2
End If

' no of possile ntwk id class b
If Val(Text1.Text) >= 128 Then
Text14.Text = 2 ^ 14
End If

' no of possile ntwk id class c
If Val(Text1.Text) >= 192 Then
Text14.Text = 2 ^ 21
End If

'usable no of ntwkid bits 4 class a
If Val(Text1.Text) <= 126 Then
Text15.Text = 2 ^ 3 - 1
End If

'usable no of ntwkid bits 4 class b
If Val(Text1.Text) >= 128 Then
Text15.Text = 2 ^ 4 - 2
End If
'usable no of ntwkid bits 4 class c
If Val(Text1.Text) >= 192 Then
Text15.Text = 24 - 3 'since its a class c ip address its have 24 bits at the ntwk portion i.e NNNH-3
End If



End Sub


Private Sub Command3_Click()
Dim a As String
a = MsgBox("Sure to exit?", vbQuestion + vbYesNo, "Exiting...")
If a = vbNo Then Exit Sub


Unload Me
End Sub

Private Sub Text1_Change()
'Combo1.Enabled = True
'Combo1.Text = 255
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
'If Not IsNumeric(Text1.Text) Then Exit Sub

If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Text2_Change()
'Dim x As Integer
'Text2.Text = x


'Combo2.Enabled = True
'If ip1 < 191 Then
'Combo2.Text = 255
'End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
On Error Resume Next
'If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
'KeyAscii = 0
'End If
'MsgBox "Only three Characters allowed"
'End If
If Val(Text2.Text) >= 255 Then
MsgBox "Only values lessthan 255 are allowed"
End If
End Sub

Private Sub Text3_Change()
Combo3.Enabled = True
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Text4_Change()
Combo4.Enabled = True
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
'If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
'KeyAscii = 0
'End If
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) < "0" Or Chr(KeyAscii) > "9" Then
KeyAscii = 0
End If
End Sub







User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 21 Feb, 2008 - 05:18 AM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,923



Thanked 118 times

Dream Kudos: 8475

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


You're going to provide an explanation of what you're having trouble with, not just a title of "ip calc" and post your code. We need to know what you're attempting to do, what errors you're receiving (if any), and a detailed explanation of what this code does, what you need it to do, etc.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 02:25AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month