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

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




ip calculator using visual basic 6.0

 
Reply to this topicStart new topic

ip calculator using visual basic 6.0

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


New D.I.C Head

*
Joined: 21 Feb, 2008
Posts: 2

This are the ip calc code. please i am finding it difficullt to fixed a radio botton that would always indicate the class of the ip add.
I would me much greatefull if a new or a more enhanced ip calc code is snnt to me or mine being modified thank you very much




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

Nykc
post 21 Feb, 2008 - 11:11 AM
Post #2


sudo rm -R /

Group Icon
Joined: 14 Sep, 2007
Posts: 4,018



Thanked 12 times

Dream Kudos: 275
My Contributions


Welcome to </DIC>
Hope to see you around the forums someday!
User is offlineProfile CardPM

Go to the top of the page

WolfCoder
post 21 Feb, 2008 - 11:13 AM
Post #3


ギュウ~

Group Icon
Joined: 5 May, 2005
Posts: 3,566



Thanked 5 times

Dream Kudos: 1450
My Contributions


Welcome to Dreamscode ^^
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 22 Feb, 2008 - 04:51 AM
Post #4


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


Welcome to </dream.in.code> Najib, glad you could make it! Hope to see you around the forums someday smile.gif

Happy Coding!
User is offlineProfile CardPM

Go to the top of the page

Jayman
post 24 Feb, 2008 - 01:41 AM
Post #5


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,839



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Moved to Visual Basic forum.
User is offlineProfile CardPM

Go to the top of the page

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

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