Monday, December 17, 2007

DateTimePicker on DatagridView


Imports System

Imports System.Windows.Forms

Public Class CalendarColumn
Inherits DataGridViewColumn

Public Sub New()
MyBase.New(New CalendarCell())
End Sub

Public Overrides Property CellTemplate() As DataGridViewCell
Get
Return MyBase.CellTemplate
End Get
Set(ByVal value As DataGridViewCell)

' Ensure that the cell used for the template is a CalendarCell.
If (value IsNot Nothing) AndAlso _
Not value.GetType().IsAssignableFrom(GetType(CalendarCell)) _
Then
Throw New InvalidCastException("Must be a CalendarCell")
End If
MyBase.CellTemplate = value

End Set
End Property

End Class

Public Class CalendarCell
Inherits DataGridViewTextBoxCell

Public Sub New()
' Use the short date format.
Me.Style.Format = "d"
End Sub

Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
ByVal initialFormattedValue As Object, _
ByVal dataGridViewCellStyle As DataGridViewCellStyle)

' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _
dataGridViewCellStyle)

Dim ctl As CalendarEditingControl = _
CType(DataGridView.EditingControl, CalendarEditingControl)
ctl.Value = CType(Me.Value, DateTime)

End Sub

Public Overrides ReadOnly Property EditType() As Type
Get
' Return the type of the editing contol that CalendarCell uses.
Return GetType(CalendarEditingControl)
End Get
End Property

Public Overrides ReadOnly Property ValueType() As Type
Get
' Return the type of the value that CalendarCell contains.
Return GetType(DateTime)
End Get
End Property

Public Overrides ReadOnly Property DefaultNewRowValue() As Object
Get
' Use the current date and time as the default value.
Return DateTime.Now
End Get
End Property

End Class

Class CalendarEditingControl
Inherits DateTimePicker
Implements IDataGridViewEditingControl

Private dataGridViewControl As DataGridView
Private valueIsChanged As Boolean = False
Private rowIndexNum As Integer

Public Sub New()
Me.Format = DateTimePickerFormat.Short
End Sub

Public Property EditingControlFormattedValue() As Object _
Implements IDataGridViewEditingControl.EditingControlFormattedValue

Get
Return Me.Value.ToShortDateString()
End Get

Set(ByVal value As Object)
If TypeOf value Is String Then
Me.Value = DateTime.Parse(CStr(value))
End If
End Set

End Property

Public Function GetEditingControlFormattedValue(ByVal context _
As DataGridViewDataErrorContexts) As Object _
Implements IDataGridViewEditingControl.GetEditingControlFormattedValue

Return Me.Value.ToShortDateString()

End Function

Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As _
DataGridViewCellStyle) _
Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl

Me.Font = dataGridViewCellStyle.Font
Me.CalendarForeColor = dataGridViewCellStyle.ForeColor
Me.CalendarMonthBackground = dataGridViewCellStyle.BackColor

End Sub

Public Property EditingControlRowIndex() As Integer _
Implements IDataGridViewEditingControl.EditingControlRowIndex

Get
Return rowIndexNum
End Get
Set(ByVal value As Integer)
rowIndexNum = value
End Set

End Property

Public Function EditingControlWantsInputKey(ByVal key As Keys, _
ByVal dataGridViewWantsInputKey As Boolean) As Boolean _
Implements IDataGridViewEditingControl.EditingControlWantsInputKey

' Let the DateTimePicker handle the keys listed.
Select Case key And Keys.KeyCode
Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, _
Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp

Return True

Case Else
Return False
End Select

End Function

Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) _
Implements IDataGridViewEditingControl.PrepareEditingControlForEdit

' No preparation needs to be done.

End Sub

Public ReadOnly Property RepositionEditingControlOnValueChange() _
As Boolean Implements _
IDataGridViewEditingControl.RepositionEditingControlOnValueChange

Get
Return False
End Get

End Property

Public Property EditingControlDataGridView() As DataGridView _
Implements IDataGridViewEditingControl.EditingControlDataGridView

Get
Return dataGridViewControl
End Get
Set(ByVal value As DataGridView)
dataGridViewControl = value
End Set

End Property

Public Property EditingControlValueChanged() As Boolean _
Implements IDataGridViewEditingControl.EditingControlValueChanged

Get
Return valueIsChanged
End Get
Set(ByVal value As Boolean)
valueIsChanged = value
End Set

End Property

Public ReadOnly Property EditingControlCursor() As Cursor _
Implements IDataGridViewEditingControl.EditingPanelCursor

Get
Return MyBase.Cursor
End Get

End Property

Protected Overrides Sub OnValueChanged(ByVal eventargs As EventArgs)

' Notify the DataGridView that the contents of the cell have changed.
valueIsChanged = True
Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)
MyBase.OnValueChanged(eventargs)

End Sub

End Class

Public Class Form1
Inherits Form

Private dataGridView1 As New DataGridView()

_
Public Shared Sub Main()
Application.Run(New Form1())
End Sub

Public Sub New()
Me.dataGridView1.Dock = DockStyle.Fill
Me.Controls.Add(Me.dataGridView1)
Me.Text = "DataGridView calendar column demo"
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles Me.Load

Dim col As New CalendarColumn()
Me.dataGridView1.Columns.Add(col)
Me.dataGridView1.RowCount = 5
Dim row As DataGridViewRow
For Each row In Me.dataGridView1.Rows
row.Cells(0).Value = DateTime.Now
Next row

End Sub

End Class



Sunday, October 14, 2007

File Handling with StreamReader and StreamWriter using Dialogs!


This is the code:
----------------
'
'
'Sequence 1 Task 11 open file special isntruction
Private Sub Buttons1t11importsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttons1t11importsi.Click
Try
OpenFileDialogs1t11.Filter = "Rich Text Files(*.rtf)|*.rtf|MS Documents(*.doc)|*.doc|" & _
"All files(*.*)|*.*"

If OpenFileDialogs1t11.ShowDialog = Windows.Forms.DialogResult.OK Then
OpenFileDialogs1t11.ShowHelp = True

Dim fs As New FileStream(OpenFileDialogs1t11.FileName, FileMode.Open)

Dim sr As New StreamReader(fs)
RichTextBoxs1t11si.Rtf = sr.ReadToEnd()
sr.Close()
fs.Close()

End If

Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub


'
'
'Sequence 1 Task 11 save file special instruction
Private Sub Buttons1t11editsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttons1t11editsi.Click
Try
SaveFileDialogs1t11.Filter = "Rich Text Files(*.rtf)|*.rtf|MS Documents(*.doc)|*.doc|" & _ "All files(*.*)|*.*"

If SaveFileDialogs1t11.ShowDialog = Windows.Forms.DialogResult.OK Then
SaveFileDialogs1t11.ShowHelp = True

Dim fs As New FileStream(SaveFileDialogs1t11.FileName, FileMode.OpenOrCreate)

Dim sw As New StreamWriter(fs)
sw.Write(RichTextBoxs1t11si.Rtf)
sw.Close()
fs.Close()

End If
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub


'
'
'Sequence 1 Task 11 format
Private Sub Buttons1t11format_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttons1t11format.Click
Try
If FontDialogs1t1.ShowDialog = Windows.Forms.DialogResult.OK Then
FontDialogs1t1.ShowHelp = True

'for work instruction
RichTextBoxs1t11wi.SelectionFont = FontDialogs1t1.Font
RichTextBoxs1t11wi.SelectionColor = FontDialogs1t1.Color

'for special instruction
RichTextBoxs1t11si.SelectionFont = FontDialogs1t1.Font
RichTextBoxs1t11si.SelectionColor = FontDialogs1t1.Color

End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Friday, September 21, 2007

VB.NET's Displaying total number in Checkbox.

This post discussed on how to display the total task when a checkbox control is checked.




This is the code:
----------------

Imports System.Windows.Forms.CheckBox
Imports MySql.Data.MySqlClient
Imports System.IO

Public Class Production_Sequence
Dim totaltask As Integer = 0

Dim Production_Sequence() As Integer = {13, 2, 2, 2, 2, 3, 4, 5, 2, 2, 2, 2, 3, 9, 4, _
2, 1, 4, 13, 10, 5, 4, 4, 1, 3, 3, 3, 1, 1, 5, 1, 3, 4, 4, 1, 2, 1}

Dim checkbox() As CheckBox = New CheckBox() {CheckBoxProductionSequence1, CheckBoxProductionSequence2, CheckBoxProductionSequence2_1, _
CheckBoxProductionSequence3, CheckBoxProductionSequence4, CheckBoxProductionSequence4_1, CheckBoxProductionSequence5, CheckBoxProductionSequence6, _
CheckBoxProductionSequence7, CheckBoxProductionSequence8, CheckBoxProductionSequence9, CheckBoxProductionSequence10, CheckBoxProductionSequence11, _
CheckBoxProductionSequence12, CheckBoxProductionSequence13, CheckBoxProductionSequence14, CheckBoxProductionSequence15, CheckBoxProductionSequence16, _
CheckBoxProductionSequence17, CheckBoxProductionSequence18, CheckBoxProductionSequence19, CheckBoxProductionSequence20, CheckBoxProductionSequence21, _
CheckBoxProductionSequence22, CheckBoxProductionSequence23, CheckBoxProductionSequence24, CheckBoxProductionSequence25, CheckBoxProductionSequence26, _
CheckBoxProductionSequence27, CheckBoxProductionSequence28, CheckBoxProductionSequence29, CheckBoxProductionSequence30, CheckBoxProductionSequence31, _
CheckBoxProductionSequence32, CheckBoxProductionSequence33, CheckBoxProductionSequence34, CheckBoxProductionSequence35}

Public Function TotalProductionTask(ByVal x) As Short
Try
If checkbox(x).Checked = True Then
totaltask = totaltask + Production_Sequence(x)
Else
totaltask = totaltask - Production_Sequence(x)
End If

TotalProductionTask = totaltask

Catch ex As Exception
MsgBox(ex.Message)
End Try



End Function


Private Sub CheckBoxProductionSequence1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence1.CheckedChanged
Try
checkbox(0) = CheckBoxProductionSequence1
TextBoxTotalTask.Text = TotalProductionTask(0)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence2.CheckedChanged
Try
checkbox(1) = CheckBoxProductionSequence2
TextBoxTotalTask.Text = TotalProductionTask(1)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence2_1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence2_1.CheckedChanged
Try
checkbox(2) = CheckBoxProductionSequence2_1
TextBoxTotalTask.Text = TotalProductionTask(2)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence3.CheckedChanged
Try
checkbox(3) = CheckBoxProductionSequence3
TextBoxTotalTask.Text = TotalProductionTask(3)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence4.CheckedChanged
Try
checkbox(4) = CheckBoxProductionSequence4
TextBoxTotalTask.Text = TotalProductionTask(4)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence4_1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence4_1.CheckedChanged
Try
checkbox(5) = CheckBoxProductionSequence4_1
TextBoxTotalTask.Text = TotalProductionTask(5)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence5.CheckedChanged
Try
checkbox(6) = CheckBoxProductionSequence5
TextBoxTotalTask.Text = TotalProductionTask(6)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence6.CheckedChanged
Try
checkbox(7) = CheckBoxProductionSequence6
TextBoxTotalTask.Text = TotalProductionTask(7)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence7.CheckedChanged
Try
checkbox(8) = CheckBoxProductionSequence7
TextBoxTotalTask.Text = TotalProductionTask(8)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence8.CheckedChanged
Try
checkbox(9) = CheckBoxProductionSequence8
TextBoxTotalTask.Text = TotalProductionTask(9)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence9.CheckedChanged
Try
checkbox(10) = CheckBoxProductionSequence9
TextBoxTotalTask.Text = TotalProductionTask(10)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence10.CheckedChanged
Try
checkbox(11) = CheckBoxProductionSequence10
TextBoxTotalTask.Text = TotalProductionTask(11)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence11.CheckedChanged
Try
checkbox(12) = CheckBoxProductionSequence11
TextBoxTotalTask.Text = TotalProductionTask(12)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence12.CheckedChanged
Try
checkbox(13) = CheckBoxProductionSequence12
TextBoxTotalTask.Text = TotalProductionTask(13)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence13.CheckedChanged
Try
checkbox(14) = CheckBoxProductionSequence13
TextBoxTotalTask.Text = TotalProductionTask(14)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence14.CheckedChanged
Try
checkbox(15) = CheckBoxProductionSequence14
TextBoxTotalTask.Text = TotalProductionTask(15)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence15.CheckedChanged
Try
checkbox(16) = CheckBoxProductionSequence15
TextBoxTotalTask.Text = TotalProductionTask(16)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence16.CheckedChanged
Try
checkbox(17) = CheckBoxProductionSequence16
TextBoxTotalTask.Text = TotalProductionTask(17)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence17_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence17.CheckedChanged
Try
checkbox(18) = CheckBoxProductionSequence17
TextBoxTotalTask.Text = TotalProductionTask(18)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence18_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence18.CheckedChanged
Try
checkbox(19) = CheckBoxProductionSequence18
TextBoxTotalTask.Text = TotalProductionTask(19)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence19_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence19.CheckedChanged
Try
checkbox(20) = CheckBoxProductionSequence19
TextBoxTotalTask.Text = TotalProductionTask(20)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence20_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence20.CheckedChanged
Try
checkbox(21) = CheckBoxProductionSequence20
TextBoxTotalTask.Text = TotalProductionTask(21)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence21_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence21.CheckedChanged
Try
checkbox(22) = CheckBoxProductionSequence21
TextBoxTotalTask.Text = TotalProductionTask(22)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence22_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence22.CheckedChanged
Try
checkbox(23) = CheckBoxProductionSequence22
TextBoxTotalTask.Text = TotalProductionTask(23)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence23_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence23.CheckedChanged
Try
checkbox(24) = CheckBoxProductionSequence23
TextBoxTotalTask.Text = TotalProductionTask(24)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence24_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence24.CheckedChanged
Try
checkbox(25) = CheckBoxProductionSequence24
TextBoxTotalTask.Text = TotalProductionTask(25)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence25_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence25.CheckedChanged
Try
checkbox(26) = CheckBoxProductionSequence25
TextBoxTotalTask.Text = TotalProductionTask(26)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence26_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence26.CheckedChanged
Try
checkbox(27) = CheckBoxProductionSequence26
TextBoxTotalTask.Text = TotalProductionTask(27)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence27_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence27.CheckedChanged
Try
checkbox(28) = CheckBoxProductionSequence27
TextBoxTotalTask.Text = TotalProductionTask(28)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence28_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence28.CheckedChanged
Try
checkbox(29) = CheckBoxProductionSequence28
TextBoxTotalTask.Text = TotalProductionTask(29)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence29_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence29.CheckedChanged
Try
checkbox(30) = CheckBoxProductionSequence29
TextBoxTotalTask.Text = TotalProductionTask(30)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence30_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence30.CheckedChanged
Try
checkbox(31) = CheckBoxProductionSequence30
TextBoxTotalTask.Text = TotalProductionTask(31)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence31_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence31.CheckedChanged
Try
checkbox(32) = CheckBoxProductionSequence31
TextBoxTotalTask.Text = TotalProductionTask(32)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence32_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence32.CheckedChanged
Try
checkbox(33) = CheckBoxProductionSequence32
TextBoxTotalTask.Text = TotalProductionTask(33)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence33_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence33.CheckedChanged
Try
checkbox(34) = CheckBoxProductionSequence33
TextBoxTotalTask.Text = TotalProductionTask(34)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence34_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence34.CheckedChanged
Try
checkbox(35) = CheckBoxProductionSequence34
TextBoxTotalTask.Text = TotalProductionTask(35)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Private Sub CheckBoxProductionSequence35_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence35.CheckedChanged
Try
checkbox(36) = CheckBoxProductionSequence35
TextBoxTotalTask.Text = TotalProductionTask(36)
Catch ex As Exception
MsgBox(ex.ToString)

End Try
End Sub

Thursday, August 30, 2007

Data Providers of .NET Framework

  • SQL Server: Namespace(Imports System.Data.SqlClient)
  • OLE DB: Namespace(Imports System.Data.OLEDB)
  • MySQL: Namespace(Imports System.Data.MySqlClient)
  • Oracle: Namespace(Imports Oracle.DataAccess.Client)
  • Oracle: Namespae(Imports System.Data.OracleClient)
  • MaxDB: Namespace(Imports MaxDB.Data)
  • ODBC: Namespace(Imports System.Data.Odbc)

- You have to add reference before you can import.

Monday, June 11, 2007

Surrogate Technologies Predating IPv6 excluding IPv4

  1. VLSM - Variable Length Subnet Masking
  2. CIDR - Classless InterDomain Routing
  3. Supernetting -
  4. NAT - Network Address Translation
et al...

Saturday, June 9, 2007

Case Studies (Software and Web Development)

Studies include:
  • Web
  • Desktop Application
  • Distributed Systems
  • Embedded Systems
  • Microcontroller/Microprocessor
  • Mobile Systems
  • Operating Systems
  • RDBMS and Non-RDBMS
  • Business Application
  • et al...
*******************************************************************************

Case Study 1:

In this blog http://ian-mars.blogspot.com - complete / finish the 1) IPv4 subnet calculator using javascript and html the technologies supported in this blogsite.


Case Study 2:

Make your personal http sites a 1) web 2.0 compliant web site and 2) dynamic with 3) database connectivity for the collection of data like your books, codes, et al... And implement a 4) web robots on your site, 5) A shopping cart for Ecommerce, 6) and implement a built in search. Then test it using the web 2.0 validator and w3c validator to test if it conforms to the standards defined by the standardization body.


Monday, June 4, 2007

All About Database

Using the MySQL query browser to connect to the server.








Connecting to a MySQL server with different port numbers


Friday, June 1, 2007

My Vacation in Zamboanga, Aurora del Sur

Life is not just 0's and 1's. I had studied this fascinating machine and it's mercenaries of myriad technologies almost all my life. As I studied further I realized that there are more to life than just computers.

Life is beautiful however I also wanted to be an independent individual and the key to my independence are these technologies, getting all the necessary information to stay at the top of my profession.

There are things in life that are more important to these elusive dreams of mine. I had worked in different companies with different positions, yet still I easily get bored of the routine. I found out that maybe my parents were right of taking me to a vacation in Zamboanga, Aurora.

This is the birthplace of my mother, she studied here from grades 1 to 4th year high school. She meet her old friends and they reminisce the old memories. I was amazed on how they remembered everything before. It's my second time to visit this place - the first time I think when I was still 5 or 6 years old.

I enjoyed this vacation - we went to a lot of places, taking a peek to my mothers' "hacienda", swimming pool in "Anonang" and a lot of foods and drinks.

We went here last May 28, 2007 that was Monday and we went back to Cebu on Sunday that would be June 3, 2007. Thanks to this internet cafe I was able to wrote this vacation experience.

Thursday, May 3, 2007

Case Studies (Networking Labs)

Case Study 1:(IPv4 subnet addressing scheme)

1) Figure out how many subnets to create.
2) How many LAN's and WAN's
3) Develop an IP addressing scheme.
4) Assign an IP address on each machine.
Note: Subnet Address
is assigned to each interface like E0, E1, S0, S1, T0, T1, et al... Subnet mask and a valid range of Host Address.





Answers Case Study 1:

1) 8 subnets needed

2) LAN=5 WAN=3

3) IP Addressing scheme

LAB-A
Given E0:
192.5.5.1 --> Class C

Required:
--> since 2 bits must be left in borrowing bits from host portion of the IPv4 address (Network and Broadcast Address)
just borrow 6 bits max
2^4 = 16-2 = 14 subnets

Solution:
192.5.5.1/24
AND
255.255.255.0/24 -->Default Subnet Mask
--------------
192.5.5.0/24 -->Network Address(Subnet 0)

192.5.5.11110000/28
192.5.5.240/28 (last subnet address)

255.255.255.240/28 --> Custom Subnet Mask

2^4=16-2=14 hosts/subnet

Subnet Address <---> Broadcast Address <---> Host Range Address
0) 192.5.5.0/28 <--->192.5.5.15/28 <-----> 192.5.5.1/28~192.5.5.14/28
1) 192.5.5.16 /28 <-> 192.5.5.31 /28 <----> 192.5.5.17/28~192.5.5.30/28
2) 192.5.5.32/28 <-> 192.5.5.47/28 <----> 192.5.5.33/28~192.5.5.46/28
3) 192.5.5.48/28 <-> 192.5.5.63/28 <----> 192.5.5.49/28~192.5.5.62/28
*
*
*
14) 192.5.5.240/28 <----> 192.5.5.255/28 <--> 192.5.5.241/28~192.5.5.254/28

Given E1:
205.7.5.1/24 --> Class C

Solution:
2^4 = 16-2 = 14 subnets

205.7.5.1/24
AND
255.255.255.0/24 --> D.S.M.
---------------
205.7.5.0/24 -->N.A

205.7.5.11110000/28=205.7.5.240/28(last subnet)
255.255.255.240/28 --> C.S.M.

Subnet Address <---> Broadcast Address <---> Host Range Address
0) 205.7.5.0/28 <--> 205.7.5.15 <------> 205.7.5.1~205.7.5.14
1) 205.7.5.16/28 <-> 205.7.5.31/28 <-----> 205.7.5.17/28~205.7.5.30/28
2) 205.7.5.32/28 <-> 205.7.5.47/28 <----> 205.7.5.33/28~205.7.5.46/28
*
*
*
14)205.7.5.240/28 <----> 250.7.5.255 /28<----> 205.7.5.241/28~250.7.5.254/28


Given S0:
201.100.11.1

Solution:

201.100.11.1
AND
255.255.255.0/24 --> Default Subnet mask
---------------
201.100.11.0/24 -->Subnet 0 (Network Address)

2^4 = 16-2 = 14 subnets

201.100.11.11110000/28= 201.100.11.240/28(last subnet)
255.255.255.240/28 --> Custom Subnet Mask

Subnet Address <---> Broadcast Address <---> Host Range Address
0) 201.100.11.0/28 <-> 201.100.11.15 <--> 201.100.11.1~201.100.11.14
1) 201.100.11.16/28 <-> 201.100.11.31/28 <--> 201.100.11.17/28~201.100.11.30/28
2) 201.100.11.32/28 <-> 201.100.11.47/28 <--> 201.100.11.33/28~201.100.11.46/28
*
*
62) 201.100.11.240/28 <--> 201.100.11.255/30 <--> 201.100.11.241/30~201.100.11.254/30














































































































































































































































4) ROUTER(2514) LAB CONFIGURATION
Step Description/ExplanationRouter Command PromptIOS Command
Enable privileged modeRouter>enable
Configure(the router) from Terminal(keyboard)Router#config t
Name Router LAB-A (the prompt will change)Router(config)#Hostname LAB-A
Set privileged mode encrypted (secret) password to classLAB-A(config)#Enable secret class
Set privileged mode text password (optional)LAB-A(config)#Enable password cisco
Disable DNS lookupLAB-A(config)#No ip domain-lookup
Select E0 interfaceLAB-A(config)#Interface Ethernet0
Provide description for E0 (optional on any interface)LAB-A(config-if)#Description connected to LAN A
Set E0 IP address and subnet maskLAB-A(config-if)#ip address 192.5.5.1 255.255.255.0 ¿
Bring interface E0 upLAB-A(config-if)#No shutdown
Save interface configurationLAB-A(config-if)#Cntrl Z
Select E1 interfaceLAB-A(config-if)#Interface Ethernet1
Set E1 IP address and subnet maskLAB-A(config-if)#ip address 205.7.5.0 255.255.255.0 ¿
Bring interface E1 upLAB-A(config-if)#No shutdown
Save interface configurationLAB-A(config-if)#Cntrl Z
Select S0 interfaceLAB-A(config-if)#Interface Serial0
Set S0 IP address and subnet maskLAB-A(config-if)#ip address 201.100.11.1 255.255.255.0 ¿
Set IGRP bandwidth metricLAB-A(config-if)#Bandwidth 56
Set DCE clock synch at 56000LAB-A(config-if)#Clock rate 56000
Bring interface S0 upLAB-A(config-if)#No shutdown
Save interface configurationLAB-A(config-if)#Cntrl Z
Select S1 interface(not used)LAB-A(config-if)#Interface Serial1
Set no IP address for S1LAB-A(config-if)#No ip address
Administratively shutdown S1LAB-A(config-if)#Shutdown
Exit interface config modeLAB-A(config-if)#Exit
Start RIP routing protocolLAB-A(config)#Router rip
Specify directly connected network for routing updatesLAB-A(config-router)#Network 192.5.5.0
Specify directly connected network for routing updatesLAB-A(config-router)#Network 205.7.5.0
Specify directly connected network for routing updatesLAB-A(config-router)#Network 201.100.11.0
Exit router config modeLAB-A(config-router)#Exit
Define router host name table

Specify host table entry for Lab-A(with interface IP address)LAB-A(config)#Ip host LAB-A 192.5.5.1 205.7.5.1 201.100.11.1
Specify host table entry for Lab-A(with interface IP address)LAB-A(config)#Ip host LAB-B 219.17.100.1 199.6.13.1 201.100.11.2
Specify host table entry for Lab-A(with interface IP address)LAB-A(config)#Ip host LAB-C 223.8.151.1 204.204.7.1 199.6.13.2
Specify host table entry for Lab-A(with interface IP address)LAB-A(config)#Ip host LAB-D 210.93.105.1 204.204.7.2
Specify host table entry for Lab-A(with interface IP address)LAB-A(config)#Ip host LAB-E 210.93.105.2
Disable classless IP routingLAB-A(config)#No ip classless
Configure console line(direct attached to console port)LAB-A(config)#Line con 0
Enable console login password checkingLAB-A(config-line)#Login
Set user mode password for console connection loginLAB-A(config-line)#Password cisco
Configure telnet line(virtual terminal or VTY)
LAB-A(config-line)#Line vty 0 4
Enable telnet login passwordLAB-A(config-line)#Login
Set user mode password for telnet connection loginLAB-A(config-line)#Password cisco
Save line configurationLAB-A(config-line)#Cntrl Z
Save the current running configuration to the startup configurationLAB-A#Copy running-config startup-config






Case Study 2:

Wednesday, April 4, 2007

IPv6 compatible IPv4

Structure of IPv4:

32 bits dotted decimal

e.g

100.25.200.100

***********************************************************************
***********************************************************************

Structure of IPv6:

128 bits colon hexadecimal

e.g

0000:0000:0000:0000:0000:0000:0000:0000
or
0000::0000 (loopback address)


Conversion:

IPv4

172.163.1.200

Binary
1010 1100.1010 0011.0000 0001.1100 1000

IPv6
0000::ACA3:01C8


For a more detailed info click on the list on the right side or click me

Monday, April 2, 2007

IPv4 Classfull Subnet Addressing - (Class A, Class B, Class C)

1st octet . 2nd octet . 3rd octet . 4th octet




Class A = 1 - 126.0.0.0/8

0

Internet address space

N.H.H.H

Default Subnet Mask = 255.0.0.0/8

Number of Networks = 2^7 = 128-2 = 126

Hosts/Network(usable addresses) = 2^24 = 16,777,216-2 = 16,777,214

Class B = 128 - 191.0.0.0/16

10

Company address space

N.N.H.H

Default Subnet Mask = 255.255.0.0/16

Number of Networks = 2^14 = 16,384-2 = 16,382

Hosts/Network(usable addresses) = 2^16 = 65,536-2 = 65,534

Class C = 192 - 223.0.0.0/24

110

Arbitrary address space

N.N.N.H

Default Subnet Mask = 255.255.255.0/24

Number of Networks = 2^21 = 2,097,152-2 = 2,097,150

Hosts/Network(usable addresses) = 2^8 = 256-2 = 254

Class D = 224 - 239

1110

Multicasting

Class E = 240 - 254

11110

Military



Private IP Address: (RFC 1918)

Class A

10.x.x.x/8

Class B

172.30.x.x/16

Class C

192.168.x.x/24



************************************************************************************
************************************************************************************

Class A IP Address

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given:
10.0.200.100
Problem: I need a total of 126 subnets

Solution:


::2^7=128-2=126
Total Network=126

::
2^7 = 128-2=126
Total Subnets=126

::2^17=131,072-2=131,070
Total Host/Subnet=131,070

You need to borrow 7 bits from Host Bits in Network Address


Find the Network Address:
10.0.200.100 --> Given IP Address
AND
255.0.0.0/8 --> Default Subnet Mask (Class A)
-------------------
10.0.0.0/8 --> Network Address(Subnet 0 = unusable -->wire address)

Then borrow 7 bits from Host bits in Network Address:
10.11111110.0.0/15
10.254.0.0/15
--> Last Subnet=subnet 127(unusable)

Last usable subnet:
-----------------------------
Last usable subnet = Last unusable subnet - Lowest Significant Bit
10.254.0.0/15 - 2 = 10.252.0.0/15



255.254.0.0/15
--> Custom Subnet Mask


Subnet Address <---> Broadcast Address <--->Host Range
0) 10.0.0.0 <----->10.1.255.255 <----->10.0.0.1~10.1.255.254
1) 10.2.0.0 <----->10.3.255.255 <----->10.2.0.1~10.3.255.254
2) 10.4.0.0 <----->10.5.255.255 <----->10.4.0.1~10.5.255.254
3) 10.6.0.0 <----->10.7.255.255 <----->10.6.0.1~10.7.255.254
4) 10.8.0.0 <----->10.9.255.255 <----->10.8.0.1~10.9.255.254
5) 10.10.0.0 <---> 10.11.255.255 <---> 10.10.0.1~10.11.255.254
6) 10.12.0.0 <---> 10.13.255.255 <---> 10.12.0.1~10.13.255.254
7) 10.14.0.0 <---> 10.15.255.255 <---> 10.14.0.1~10.15.255.254
8) 10.16.0.0 <---> 10.17.255.255 <---> 10.16.0.1~10.17.255.254
9) 10.18.0.0 <---> 10.19.255.255 <---> 10.18.0.1~10.19.255.254
10) 10.20.0.0 <-> 10.21.255.255 <---> 10.20.0.1~10.21.255.254
11) 10.22.0.0 <--> 10.23.255.255 <--> 10.22.0.1~10.23.255.254
12) 10.24.0.0 <--> 10.25.255.255 <--> 10.24.0.1~10.25.255.254
13) 10.26.0.0 <--> 10.27.255.255 <--> 10.26.0.1~10.27.255.254
14) 10.28.0.0 <--> 10.29.255.255 <--> 10.28.0.1~10.29.255.254
15) 10.30.0.0 <--> 10.31.255.255 <--> 10.30.0.1~10.31.255.254
16) 10.32.0.0 <--> 10.33.255.255 <--> 10.32.0.1~10.33.255.254
17) 10.34.0.0 <--> 10.35.255.255 <--> 10.34.0.1~10.35.255.254
18) 10.36.0.0 <--> 10.37.255.255 <--> 10.36.0.1~10.37.255.254
19) 10.38.0.0 <--> 10.39.255.255 <--> 10.38.0.1~10.39.255.254
20) 10.40.0.0 <--> 10.41.255.255 <--> 10.40.0.1~10.41.255.254
*
*
*
*
126)10.252.0.0 <-> 10.253.255.255 <-> 10.252.0.1~10.253.255.254
127)10.254.0.0 <-> 10.254.255.255 <----------> unusable

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 10.60.12.250
Problem: 9 Subnets

Solution:

::2^7=128-2=126
Total Networks=126

::2^4=16-2=14
Total Subnets=14

::2^20=1,048,576-2=1048574
Total Hosts/Subnet=
1048574

Borrow 4 bits from Host bits in N.A.


10.60.12.250

AND
255.0.0.0/8 -->DSM
------------------
10.0.0.0/8 -->NA

10.11110000.0.0/12
10.240.0.0/12
--->Subnet 15=last subnet(unusable)

Last usable subnet:
-----------------------------
Last usable subnet = Last unusable-Lowest Significant Bit
10.240.0.0/12 - 16 = 10.224.0.0/12



255.240.0.0/12
-->CSM



Subnet Address <---> Broadcast Address <--->Host Range
0)10.0.0.0
<------->10.15.255.255<-----> 10.0.0.1~10.15.255.254
1)10.16.0.0<------>10.31.255.255 <----> 10.16.0.1~10.31.255.254
2)10.32.0.0<------>10.47.255.255 <----> 10.32.0.1~10.47.255.254
3)10.48.0.0<------>10.63.255.255 <----> 10.48.0.1~10.63.255.254
4)10.64.0.0<------>10.79.255.255 <----> 10.64.0.1~10.79.255.254
5)10.80.0.0<------>10.95.255.255 <----> 10.80.0.1~10.95.255.254
6)10.96.0.0<------>10.111.255.255 <--> 10.96.0.1~10.111.255.254
7)10.112.0.0<----> 10.127.255.255 <--> 10.112.0.1~10.127.255.254
8)10.128.0.0<---->10.143.255.255 <---> 10.128.0.1~10.143.255.254
9)10.144.0.0<---->10.159.255.255 <---> 10.144.0.1~10.159.255.254
10)10.160.0.0<--> 10.175.255.255<---> 10.160.0.1~10.175.255.254
11)10.176.0.0<--> 10.191.255.255<---> 10.176.0.1~10.191.255.254
12)10.192.0.0<--> 10.207.255.255<---> 10.192.0.1~10.207.255.254
13)10.208.0.0<--> 10.223.255.255<---> 10.208.0.1~10.223.255.254
14)10.224.0.0<--> 10.239.255.255<---> 10.224.0.1~10.239.255.254
15)10.240.0.0 <-> 10.240.255.255 <--> unusable

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 125.100.10.50
Problem:
65,534 Subnets


Solution:

::2^7=128-2=126
Total Networks

::2^16=65,536-2=65,534
Total Subnets

::2^8=256-2=254
Total Hosts/Subnets

Borrow 16 bits from Host Bits in Network Address

125.100.10.50
AND
255.0.0.0/8 --> DSM
----------------
125.0.0.0/8 --> NA

125.11111111.11111111.0/24
125.255.255.0/24 --> Last unusable subnet=subnet 65,535(unusable)

Last usable subnet:
--------------------------
65,535-1 = subnet 65,534
Last usable subnet=125.255.255.0/24 - 1 = 125.255.254.0/24

255.255.255.0/24
--> CSM

Subnet Address <---> Broadcast Address <--->Host Range
0)125.0.0.0
<---->125.0.0.255<-------> 125.0.0.1~125.0.0.254
1)125.0.1.0<---->125.0.1.255 <------> 125.0.1.1~125.0.1.254
2)125.0.2.0<---->125.0.2.255 <------>125.0.2.1~125.0.2.254
3)125.0.3.0<---->125.0.3.255 <------>125.0.3.1~125.0.3.254
4)125.0.4.0<---->125.0.4.255 <------>125.0.4.1~125.0.4.254
5)125.0.5.0<---->125.0.5.255 <------>125.0.5.1~125.0.5.254
6)125.0.6.0<---->125.0.6.255 <------>125.0.6.1~125.0.6.254
7)125.0.7.0<---->125.0.7.255 <------>125.0.7.1~125.0.7.254
8)125.0.8.0<---->125.0.8.255 <------>125.0.8.1~125.0.8.254
9)125.0.9.0<---->125.0.9.255 <------>125.0.9.1~125.0.9.254
10)125.0.10.0<->125.0.10.255 <---> 125.0.10.1~125.0.10.254
11)125.0.11.0<-->125.0.11.255 <-> 125.0.11.1~125.0.11.254
12)125.0.12.0<-->125.0.12.255 <-> 125.0.12.1~125.0.12.254
13)125.0.13.0<-->125.0.13.255 <-> 125.013.1~125.0.13.254
14)125.0.14.0<-->125.0.14.255 <--> 125.1.14.1~125.1.14.254
15)125.0.15.0<-->125.0.15.255 <-> 125.0.15.1~125.0.15.254
* *
* *
* *
* *
65,534) 125.255.254.0 <-> 125.255.254.255 <-> 125.255.254.1~125.255.254.254
65,535) 125.255.255.0 <--> 125.255.255.255 <---> unusable

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 120.200.168.10
Problem: I need 262,142 subnets

Solution:

::2^7=128-2=126
Total Network

::2^18=262,144-2=262,142
Total Subnets

::2^6=64-2=62
Total Hosts

Borrow 18 bits from Host bits in NA

120.200.168.10
AND
255.0.0.0
---------------------
120.0.0.0/8

120.11111111.11111111.11000000/26
120.255.255.192/26
--> Last unusable subnet=262,143 subnets(unusable)

Last usable subnet:

120.255.255.192 - 64 = 120.255.255.128/26

255.255.255.192/26
--> CSM

Subnet Address <---> Broadcast Address <--->Host Range
0)120.0.0.0
<--->120.0.0.63<-----> 120.0.0.1~120.0.0.62
1)120.0.0.64<--> 120.0.0.127 <--> 120.0.0.65~120.0.0.126
2)120.0.0.128<-> 120.0.0.191 <--> 120.0.1.129~120.0.0.190
3)120.0.0.192 <-> 120.0.0.255 <--> 120.0.0.193~120.0.0.254
4)120.0.1.0 <-----> 120.0.1.63 <---> 120.0.1.1~120.0.1.62
5)120.0.1.64 <---> 120.0.1.127<--> 120.0.1.65~120.0.1.126
6)120.0.1.128 <->120.0.1.191<---> 120.0.1.129~120.0.1.190
7)120.0.1.192 <->120.0.1.255<--->120.0.1.193~120.0.1.254
8)120.0.2.0 <---->120.0.2.63 <---->120.0.2.1~120.0.2.62
9)120.0.2.64 <-->120.0.2.127<--->120.0.2.65~120.0.2.126
10)120.0.2.128 <-->120.0.2.191<-->120.0.2.129~120.0.2.190
11)120.0.2.192 <-->120.0.2.255<-->120.0.2.193~120.0.2.254
12)120.0.3.0 <----->120.0.3.63<---->120.0.3.1~120.0.3.62
13)120.0.3.64 <--->120.0.3.127<-->120.0.3.65~120.0.3.126
14)120.0.3.128 <->120.0.3.191<-->120.0.3.129~120.0.3.190
15)120.0.3.192 <->120.0.3.255<-->120.0.3.193~120.0.3.254
16)120.0.4.0 <---->120.0.4.63<---->120.0.4.1~120.0.4.62
17)120.0.4.64 <-->120.0.4.127<-->120.0.4.65~120.0.4.126
18)120.0.4.128 <-->120.0.4.191<-->120.0.4.129~120.0.4.190
19)120.0.4.192 <-->120.0.4.255<-->120.0.4.193~120.0.4.254
20)120.0.5.0 <-----> 120.0.5.63 <--->120.0.5.1~120.0.5.62
*
*
*
262,142)120.255.255.128<>120.255.255.191<> 120.255.255.129~120.255.255.190
262,143)120.255.255.192<>120.255.255.255<> unusable


///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

Given: 110.200.100.100
Problem: 131,070 subnets

Solution:

::2^7=128-2=126
Total Networks

::2^17=131,072-2=131,072
Total Subnets

::2^7=128-2=126
Total Hosts/Subnet

Borrow 17 bits from Host bits in the NA

110.200.100.100
AND
255.0.0.0/8 --> DSM
-----------------------
110.0.0.0/8 --> NA

110.11111111.11111111.10000000/17
110.255.255.128/17
--> Last unusable subnet=subnet 131,073


Last usable subnet:
---------------------------
110.255.255.128/17 - 128 = 110.255.255.0/17
110.255.255.0/17
--> Last usable subnet = subnet 131,072


255.255.255.128/17
--> CSM


Subnet Address <---> Broadcast Address <--->Host Range
0)110.0.0.0<------> 110.0.0.127<---->110.0.0.1~110.0.0.126
1)110.0.0.128 <-->110.0.0.255 <---> 110.0.0.129~110.0.0.254
2)110.0.1.0 <-----> 110.0.1.127 <---> 110.0.1.1~110.0.1.126
3)110.0.1.128 <-> 110.0.1.255 <---> 110.0.1.129~110.0.1.254
4)110.0.2.0 <----> 110.0.2.127 <--->110.0.2.1~110.0.2.126
5)110.0.2.128 <-> 110.0.2.255 <--> 110.0.2.129~110.0.2.254
6)110.0.3.0 <----> 110.0.3.127 <--> 110.0.3.1~110.0.3.126
7)110.0.3.128 <-> 110.0.3.255 <-> 110.0.3.129~110.0.3.254
8)110.0.4.0 <----> 110.0.4.127 <--> 110.0.4.1~110.0.4.126
9)110.0.4.128 <--> 110.0.4.255 <-> 110.0.4.129~110.0.4.254
10)110.0.5.0 <---> 110.0.5.127 <--> 110.0.5.1~110.0.5.126
11)110.0.5.128 <--> 110.0.5.255 <--> 110.0.5.129~110.0.5.254
12)110.0.6.0 <-----> 110.0.6.127 <--> 110.0.6.1~110.0.6.126
13)110.0.6.128 <--> 110.0.6.255 <--> 110.0.6.129~110.0.6.254
14)110.0.7.0 <-----> 110.0.7.127 <---> 110.0.7.1~110.0.7.126
15)110.0.7.128 <-> 110.0.7.255 <---> 110.0.7.129~110.0.7.254
16)110.0.8.0 <----> 110.0.8.127 <---> 110.0.8.1~110.0.8.126
17)110.0.8.128 <--> 110.0.8.255 <--> 110.0.8.129~110.0.8.254
18)110.0.9.0 <-----> 110.0.9.127 <--> 110.0.9.1~110.0.9.126
19)110.0.9.128 <-> 110.0.9.255 <--> 110.0.9.129~110.0.9.254
20)110.0.10.0 <--> 110.0.10.127 <-> 110.0.10.1~110.0.10.126
*
*
*
131,072)110.255.255.0<>110.255.255.127<>110.255.255.1~110.255.255.126
131,073)110.255.255.128<>110.255.255.255 <----> unusable

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 10.16.5.3
Problem: I need 4,194,302 subnets

Solution:

::2^7=128-2=126
Total Networks

::2^22=4,194,304-2=4,194,302
Total Subnets

::2^2=4-2=2
Total Hosts/Subnet

Borrow 22 bits from Host bits in the NA

10.16.5.3
AND
255.0.0.0/8
-------------
10.0.0.0/8

10.11111111.11111111.11111100/22
10.255.255.252/22
--> Last unusable subnet = subnet 4,194,303

Last usable subnet:
--------------------------
10.255.255.248/22 --> Last usable subnet = subnet 4,194,302


255.255.255.248/22
--> CSM


Subnet Address <---> Broadcast Address <--->Host Range
0)10.0.0.0 <--> 10.0.0.3 <--------> 10.0.0.1~10.0.0.2
1)10.0.0.4 <--> 10.0.0.7 <--------> 10.0.0.5~10.0.0.6
2)10.0.0.8 <--> 10.0.0.11 <------> 10.0.0.9~10.0.0.10
3)10.0.0.12 <---> 10.0.0.15 <---> 10.0.0.13~10.0.0.14
4)10.0.0.16 <--> 10.0.0.19 <----> 10.0.0.17~10.0.0.18
5)10.0.0.20 <--> 10.0.0.23 <----> 10.0.0.21~10.0.0.22
6)10.0.0.24 <--> 10.0.0.27 <----> 10.0.0.25~10.0.0.26
7)10.0.0.28 <--> 10.0.0.31 <----> 10.0.0.29~10.0.0.30
8)10.0.0.32 <--> 10.0.0.35 <----> 10.0.0.33~10.0.0.34
9)10.0.0.36 <--> 10.0.0.39 <----> 10.0.0.37~10.0.0.38
10)10.0.0.40 <--> 10.0.0.43 <--> 10.0.0.41~10.0.0.42
11)10.0.0.44 <--> 10.0.0.47 <--> 10.0.0.45~10.0.0.46
12)10.0.0.48 <-> 10.0.0.51 <--> 10.0.0.49~10.0.0.50
13)10.0.0.52 <-> 10.0.0.55 <--> 10.0.0.53~10.0.0.54
14)10.0.0.56 <-> 10.0.0.59 <--> 10.0.0.57~10.0.0.58
15)10.0.0.60 <-> 10.0.0.63 <--> 10.0.0.61~10.0.0.62
16)10.0.0.64 <-> 10.0.0.67 <--> 10.0.0.65~10.0.0.66
17)10.0.0.68 <-> 10.0.0.71 <--> 10.0.0.69~10.0.0.70
18)10.0.0.72 <-> 10.0.0.75 <--> 10.0.0.73~10.0.0.74
19)10.0.0.76 <-> 10.0.0.79 <--> 10.0.0.77~10.0.0.78
20)10.0.0.80 <-> 10.0.0.83 <--> 10.0.0.81~10.0.0.82
*
*
*
4,194,302)10.255.255.248<>10.255.255.251<>10.255.255.249~10.255.255.250
4,194,303)10.255.255.252<>10.255.255.255<> unusable


##########################################################################
##########################################################################
##########################################################################
##########################################################################
##########################################################################



Class B IP Address

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 130.17.12.160
Problem:
I need 4094 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^12 = 4,096-2 = 4,094
Total Subnets

::2^4 = 16-2 = 14
Total Hosts/Subnet


Borrow 12 bits from Host bits in the Network Address

130.17.12.160
AND
255.255.0.0 /16 --> DSM
-------------------
130.17.0.0 /16 --> NA

130.17.11111111.11110000/28
130.17.255.240/28
--> Last unusable subnet = subnet 4,095

Last usable subnet:
-------------------------
130.17.255.240/28 - 16 = 130.17.255.224/28

255.255.255.240/28
--> CSM


Subnet Address <---> Broadcast Address <--->Host Range
0)130.17.0.0 <----->130.17.0.15 <----> 130.17.0.1~130.17.0.14
1)130.17.0.16 <---> 130.17.0.31 <---> 130.17.0.17~130.17.0.30
2)130.17.0.32 <---> 130.17.0.47 <---> 130.17.0.33~130.17.0.46
3)130.17.0.48 <---> 130.17.0.63 <---> 130.17.0.49~130.17.0.62
4)130.17.0.64 <---> 130.17.0.79 <---> 130.17.0.65~130.17.0.78
5)130.17.0.80 <---> 130.17.0.95 <---> 130.17.0.81~130.17.0.94
6)130.17.0.96 <---> 130.17.0.111 <--> 130.17.0.97~130.17.0.110
7)130.17.0.112 <-> 130.17.0.127 <--> 130.17.0.113~130.17.0.126
8)130.17.0.128 <-> 130.17.0.143 <--> 130.17.0.129~130.17.0.142
9)130.17.0.144 <-> 130.17.0.159 <--> 130.17.0.145~130.17.0.158
10)130.17.0.160 <-> 130.17.0.175 <--> 130.17.0.161~130.17.0.174
11)130.17.0.176 <-> 130.17.0.191 <--> 130.17.0.177~130.17.0.190
12)130.17.0.192 <-> 130.17.0.207 <-> 130.17.0.193~130.17.0.206
13)130.17.0.208 <-> 130.17.0.223 <-> 130.17.0.209~130.17.0.222
14)130.17.0.224 <--> 130.17.0.239 <--> 130.17.0.225~130.17.0.238
15)130.17.0.240 <--> 130.17.0.255 <--> 130.17.0.141~130.17.0.254
16)130.17.1.0 <-----> 130.17.1.15 <----> 130.17.1.1~130.17.1.14
17)130.17.1.16 <---> 130.17.1.31 <----> 130.17.1.17~130.17.1.30
18)130.17.1.32 <---> 130.17.1.47 <---> 130.17.1.33~130.17.1.46
19)130.17.1.48 <---> 130.17.1.63 <---> 130.17.1.49~130.17.1.62
20)130.17.1.64 <--> 130.17.1.79 <----> 130.17.1.65~130.17.1.78
*
*
*
4,094)130.17.255.224<>130.17.255.239<>130.17.255.225~130.17.255.238
4,095)130.17.255.240

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 144.1.0.0
Problem:
I need 14 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^4 = 16-2 = 14
Total Subnets

::2^12 = 4,096-2 = 4,094
Total Hosts/Subnet

Borrow 4 bits from Host bits in Network Address

144.1.0.0
AND
255.255.0.0/16 --> DSM
----------------
144.1.0.0/16
--> NA

144.1.11110000.00000000/20
144.1.240.0/20
--> Last Unusable Subnet = subnet 15

Last usable subnet:
-------------------------
144.1.224.0/20 --> Last usable subnet = subnet 14

Subnet Address <----> Broadcast Address <--->Host Range
0)144.1.0.0 <----> 144.1.15.255 <----> 144.1.0.1~144.1.15.254
1)144.1.16.0 <---> 144.1.31.255 <--->144.1.16.1~144.1.31.254
2)144.1.32.0 <---> 144.1.47.255 <---> 144.1.32.1~144.1.47.254
3)144.1.48.0 <---> 144.1.63.255 <---> 144.1.48.1~144.1.63.254
4)144.1.64.0 <---> 144.1.79.255 <---> 144.1.64.1~144.1.79.254
5)144.1.80.0 <---> 144.1.95.255 <--->144.1.80.1~144.1.95.254
6)144.1.96.0 <---> 144.1.111.255 <--> 144.1.96.1~144.1.111.254
7)144.1.112.0 <--> 144.1.127.255 <---> 144.1.112.1~144.1.127.254
8)144.1.128.0 <--> 144.1.143.255 <---> 144.1.128.1~144.1.143.254
9)144.1.144.0 <--> 144.1.159.255 <---> 144.1.144.1~144.1.159.254
10)144.1.160.0 <-> 144.1.175.255 <---> 144.1.160.1~144.1.175.254
11)144.1.176.0 <-> 144.1.191.255 <---> 144.1.176.1~144.1.191.254
12)144.1.192.0 <-> 144.1.207.255 <---> 144.1.192.1~144.1.207.254
13)144.1.208.0 <-> 144.1.223.255 <---> 144.1.208.1~144.1.223.254
14)144.1.224.0 <-> 144.1.239.255 <---> 144.1.224.1~144.1.239.254
15)144.1.240.0 <---> 144.1.255.255 <----> unused

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 190.150.12.2
Problem: I need 16, 382 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^14 = 16,384-2 = 16,382
Total Subnets

::2^2 = 4-2=2
Total Hosts/Subnet

Borrow 14 bits from Host bits in the NA

190.150.12.2
AND
255.255.0.0/16 --> Default Subnet Mask
------------------
190.150.0.0/16 --> Network Address

190.150.11111111.11111100/30
190.150.255.252/30
--> Last unusable subnet = subnet 16,383


Last usable subnet:
--------------------------
190.150.255.252/30 - 4 = 190.150.255.248/30


255.255.255.252/30
--> Custom Subnet Mask


Subnet Address<--->Broadcast Address<--->Host Range
0)190.150.0.0 <------->190.150.0.3 <----> 190.150.0.1~190.150.0.2
1)190.150.0.4 <-------> 190.150.0.7 <---> 190.150.0.5~190.150.0.6
2)190.150.0.8 <-------> 190.150.0.11 <--> 190.150.0.9~190.150.0.10
3)190.150.0.12 <------> 190.150.0.15 <--> 190.150.0.13~190.150.0.14
4)190.150.0.16 <------> 190.150.0.19 <--> 190.150.0.17~190.150.0.18
5)190.150.0.20 <------> 190.150.0.23 <--> 190.150.0.21~190.150.0.22
6)190.150.0.24 <------> 190.150.0.27 <--> 190.150.0.25~190.150.0.26
7)190.150.0.28 <------> 190.150.0.31 <--> 190.150.0.29~190.150.0.30
8)190.150.0.32 <------> 190.150.0.35 <--> 190.150.0.33~190.150.0.34
9)190.150.0.36 <------> 190.150.0.39 <---> 190.150.0.37~190.150.0.38
10)190.150.0.40 <----> 190.150.0.43 <---> 190.150.0.41~190.150.0.42
11)190.150.0.44 <----> 190.150.0.47 <---> 190.150.0.45~190.150.0.46
12)190.150.0.48 <----> 190.150.0.51 <---> 190.150.0.49~190.150.0.50
13)190.150.0.52 <----> 190.150.0.55 <---> 190.150.0.53~190.150.0.54
14)190.150.0.56 <----> 190.150.0.59 <---> 190.150.0.57~190.150.0.58
15)190.150.0.60 <----> 190.150.0.63 <---> 190.150.0.61~190.150.0.62
*
*
*
16,382)190.150.255.248 <---> 190.150.255.251 <---> 190.150.255.249~190.150.255.250
16,383)190.150.255.252 <----> 190.150.255.255 <----> unusable


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 172.168.10.10
Problem:
I need 254 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^8 = 256-2 = 254
Total Subnets

::2^8 = 256-2 = 254
Total Hosts/Subnet

Borrow 8 bits from the Host bits in NA

172.168.10.10
AND
255.255.0.0/16 --> Default Subnet Mask
-------------------
172.168.0.0/16--> Network Address

172.168.11111111.0/24
172.168.255.0/24
--> Last unusable subnet = subnet 255


Last usable subnet:
-------------------------
172.168.254.0/24


255.255.255.0/24
--> Custom Subnet Mask

Subnet Address <---> BroadCast Address <---> Host Address
0)172.168.0.0 <--> 172.168.0.255 <---> 172.168.0.1~172.168.0.254
1)172.168.1.0 <--> 172.168.1.255 <---> 172.168.1.1~172.168.1.254
2)172.168.2.0 <--> 172.168.2.255 <---> 172.168.2.1~172.168.2.254
3)172.168.3.0 <--> 172.168.3.255 <---> 172.168.3.1~172.168.3.254
4)172.168.4.0 <--> 172.168.4.255 <---> 172.168.4.1~172.168.4.254
5)172.168.5.0 <--> 172.168.5.255 <---> 172.168.5.1~172.168.5.254
6)172.168.6.0 <--> 172.168.6.255 <---> 172.168.6.1~172.168.6.254
7)172.168.7.0 <--> 172.168.7.255 <---> 172.168.7.1~172.168.7.254
8)172.168.8.0 <--> 172.168.8.255 <---> 172.168.8.1~172.168.8.254
9)172.168.9.0 <--> 172.168.9.255 <----> 172.168.9.1~172.168.9.254

*
*
*
254)172.168.254.0 <---> 172.168.254.255 <---> 172.168.254.1~172.168.254.254
255)172.168.255.0 <----> 172.168.255.255 <---> unusable


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 130.230.110.100
Problem:
I need 1,022 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Network

::2^10 = 1,024-2 = 1,022
Total Subnets

::2^6 = 64-2 = 62
Total Hosts/Subnet

Borrow 10 bits from Host bits in NA


130.230.110.100

AND
255.255.0.0/16--> DSM
------------------------
130.230.0.0/16 --> NA

130.230.11111111.11000000/26
130.230.255.192/26
--> Last unusable subnet = subnet 1,023

Last usable subnet:
-------------------------
130.230.255.192/26 - 64 = 130.230.255.128/26


255.255.255.192/26
--> CSM


Subnet Address <---> Broadcast Address <---> Host Range
0)130.230.0.0 <--> 130.230.0.63 <----> 130.230.0.1~130.230.0.62
1)130.230.0.64 <-> 130.230.0.127 <--> 130.230.0.65~130.230.0.126
2)130.230.0.128 <-> 130.230.0.191 <--> 130.230.0.129~130.230.0.190
3)130.230.0.192 <--> 130.230.0.255 <--> 130.230.0.193~130.230.0.254
4)130.230.1.0 <----->130.230.1.63 <----> 130.230.1.1~130.230.1.62
5)130.230.1.64 <---> 130.230.1.127 <--> 130.230.1.65~130.230.1.126
6)130.230.1.128 <--> 130.230.1.191 <-> 130.230.1.129~130.230.1.190
7)130.230.1.192 <--> 130.230.1.255 <-->130.230.1.193~130.230.1.254
8)130.230.2.0 <---> 130.230.2.63 <--> 130.230.2.1~130.230.2.62
9)130.230.2.64 <--> 130.230.2.127 <--> 130.230.2.65~130.230.2.126
10)130.230.2.128 <-> 130.230.2.191 <-> 130.230.2.129~130.230.2.190
11)130.230.2.192 <-> 130.230.2.255 <-> 130.230.2.193~130.230.2.254
12)130.230.3.0 <-> 130.230.3.63 <-> 130.230.3.1~130.230.3.62
13)130.230.3.64 <-> 130.230.3.127 <-> 130.230.3.65~130.230.3.126
14)130.230.3.128 <-> 130.230.3.191 <-> 130.230.3.129~130.230.3.190
15)130.230.3.192 <--> 130.230.3.255 <-> 130.230.3.193~130.230.3.254
*
*
*
1,022)130.230.255.128<---> 130.230.255.191 <---> 130.230.255.129~130.230.255.190
1,023)130.230.255.192 <--> 130.230.255.255 <---> unusable


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 172.16.0.0
Problem: 4 subnets
Sample Laboratory

Solution:

::2^14 = 16,384-2 = 16,382
Total Network

::2^4 = 16-2 = 14
Total Subnets

::2^12 = 4,096-2 = 4,094
Total Hosts/Subnet

********************************************************************************************
********************************************************************************************
* Note on borrowing host bits:
*
* In creating a subnet, borrow bits from the host portion of the IP address
*
* Network.Host
* after borrowing -->Network.Subnet.Host
*
* Bits borrowed must be >= subnets required (b^L =N)
* Never <
subnet required (b^L =N)
*

Class A

Maximum bits borrowed from hosts = 22 bits
Minimum bits borrowed from hosts = 2 bits(same with Class B and Class C)
Class B

Maximum bits borrowed from hosts = 14 bits
Class C

Maximum bits borrowed from hosts = 6 bits

********************************************************************************************
********************************************************************************************

Borrow 4 bits from the host bits in the NA

172.16.0.0
AND
255.255.0.0/16
----------------
172.16.0.0/16

172.16.11110000.00000000/20
172.16.240.0/20
--> Last unusable subnet = subnet 15

Last usable subnet:
-------------------------
172.16.240.0/20 - 16 = 172.16.224.0/20


255.255.240.0/20 --> CSM

Subnet Address <---> Broadcast Address <---> Host Range
0)172.16.0.0 <---> 172.16.15.255 <-->172.16.0.1~172.16.15.254
1)172.16.16.0 <--> 172.16.31.255 <--> 172.16.16.1~172.16.31.254
2)172.16.32.0 <--> 172.16.47.255 <--> 172.16.32.1~172.16.47.254
3)172.16.48.0 <--> 172.16.63.255 <--> 172.16.48.1~172.16.63.254
4)172.16.64.0 <--> 172.16.79.255 <--> 172.16.64.1~172.16.79.254
5)172.16.80.0 <--> 172.16.95.255 <--> 172.16.80.1~172.16.95.254
6)172.16.96.0 <--> 172.16.111.255 <-> 172.16.96.1~172.16.111.254
7)172.16.112.0 <-> 172.16.127.255 <-> 172.16.112.1~172.16.127.254
8)172.16.128.0 <-> 172.16.143.255 <-> 172.16.128.1~172.16.143.254
9)172.16.144.0 <-> 172.16.159.255 <-> 172.16.144.1~172.16.159.254
10)172.16.160.0 <-> 172.16.175.255 <-> 172.16.160.1~172.16.175.254
11)172.16.176.0 <-> 172.16.191.255 <-> 172.16.176.1~172.16.191.254
12)172.16.192.0 <-> 172.16.207.255 <-> 172.16.192.1~172.16.207.254
13)172.16.208.0 <-> 172.16.223.255 <-> 172.16.208.1~172.16.223.254
14)172.16.224.0<-->172.16.239.255<-->172.16.224.1~172.16.239.254
15)172.16.240.0 <---> 172.16.255.255 <---> unusable


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 172.16.10.53
Problem: 510 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^9 = 512-2 = 510
Total Subnets

::2^7=128-2 = 126
Total Host/Subnet

Borrow 9 bits from the host bits in NA

172.16.10.53
AND
255.255.0.0/16 --> DSM
--------------------
172.16.0.0/16 --> NA

172.16.1111111.10000000/25
172.16.255.128/25
--> Last unusable subnet = subnet 511

Last subnet usable:
--------------------------
172.16.255.128/25 - 128 = 172.16.255.0/25

255.255.255.128/25 --> CSM


Subnet Address <--> Broadcast Address <--> Host Range
0)172.16.0.0 <-----> 172.16.0.127 <---> 172.16.0.1~172.16.0.126
1)172.16.0.128 <--> 172.16.0.255 <--> 172.16.0.129~172.16.0.254
2)172.16.1.0 <--> 172.16.1.127 <--> 172.16.1.1~172.16.1.126
3)172.16.1.128 <-> 172.16.1.255 <-> 172.16.1.129~172.16.1.254
4)172.16.2.0 <--> 172.16.2.127 <--> 172.16.2.1~172.16.2.126
5)172.16.2.128 <--> 172.16.2.255 <--> 172.16.2.129~172.16.2.254
6)172.16.3.0 <--> 172.16.3.127 <--> 172.16.3.1~172.16.3.126
7)172.16.3.128 <--> 172.16.3.255 <--> 172.16.3.129~172.16.3.254
8)172.16.4.0 <--> 172.16.4.127 <--> 172.16.4.1~172.16.4.126
9)172.16.4.128 <--> 172.16.4.255 <--> 172.16.4.129~172.16.4.254
10)172.16.5.0 <--> 172.16.5.127 <--> 172.16.5.1~172.16.5.126
11)172.16.5.128 <--> 172.16.5.255 <--> 172.16.5.129~172.16.5.254
12)172.16.6.0 <--> 172.16.6.127 <--> 172.16.6.1~172.16.6.126
13)172.16.6.128 <--> 172.16.6.255 <--> 172.16.6.129~172.16.6.254
14)172.16.7.0 <--> 172.16.7.127 <--> 172.16.7.1~172.16.7.126
15)172.16.7.128 <--> 172.16.7.255 <--> 172.16.7.129~172.16.7.254
16)172.16.8.0 <--> 172.16.8.127 <--> 172.16.8.1~172.16.8.126
17)172.16.8.128 <-> 172.16.8.255 <-> 172.16.8.129~172.16.8.254
18)172.16.9.0 <--> 172.16.9.127 <-> 172.16.9.1~172.16.9.126
19)172.16.9.128 <-> 172.16.9.255 <--> 172.16.9.129~172.16.9.254
20)172.16.10.0 <-> 172.16.10.127 <--> 172.16.10.1~172.16.10.126
*
*
*
510)172.16.255.0 <--> 172.16.255.127 <--> 172.16.255.1~172.16.255.126
511)172.16.255.128


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 172.16.12.200
Problem: 7 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^8 = 256-2 = 254
Total Subnets

::2^8 = 256-2 = 254
Total Hosts/Subnet

Borrow 8 bits from the Host bits in NA

172.16.12.200
AND
255.255.0.0/16 --> DSM
--------------------
172.16.0.0/16 --> NA

172.16.11111111.0/24
172.16.255.0/24
--> Last Subnet unusable = subnet 255


Last usable subnet:
--------------------------
172.16.255.0/24 - 1 = 172.16.254.0/24


255.255.255.0/24 --> CSM

Subnet Address <--> Broadcast Address <--> Host Range
0)172.16.0.0 <---> 172.16.0.255 <--> 172.16.0.1~172.16.0.254
1)172.16.1.0 <---> 172.16.1.255 <--> 172.16.1.1~172.16.1.254
2)172.16.2.0 <---> 172.16.2.255 <--> 172.16.2.1~172.16.2.254
3)172.16.3.0 <---> 172.16.3.255 <--> 172.16.3.1~172.16.3.254
4)172.16.4.0 <---> 172.16.4.255 <--> 172.16.4.1~172.16.4.254
5)172.16.5.0 <---> 172.16.5.255 <--> 172.16.5.1~172.16.5.254
6)172.16.6.0 <---> 172.16.6.255 <--> 172.16.6.1~172.16.6.254
7)172.16.7.0 <---> 172.16.7.255 <--> 172.16.7.1~172.16.7.254
8)172.16.8.0 <---> 172.16.8.255 <--> 172.16.8.1~172.16.8.254
9)172.16.9.0 <--> 172.16.9.255 <--> 172.16.9.1~172.16.9.254
10)172.16.10.0 <--> 172.16.10.255 <--> 172.16.10.1~172.16.10.254
11)172.16.11.0 <--> 172.16.11.255 <--> 172.16.11.1~172.16.11.254
12)172.16.12.0 <--> 172.16.12.255 <--> 172.16.12.1~172.16.12.254
13)172.16.13.0 <--> 172.16.13.255 <--> 172.16.13.1~172.16.13.254
14)172.16.14.0 <--> 172.16.14.255 <--> 172.16.14.1~172.16.14.254
15)172.16.15.0 <--> 172.16.15.255 <--> 172.16.15.1~172.16.15.254
*
*
*
254)172.16.254.0
255)172.16.255.0


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 130.191.3.3
Problem:
Find the 200th subnet

Solution:

::2^14 = 16,384-2 = 16,382
Total Networks

::2^8 = 256-2 = 254
Total Subnets

::2^8 = 256-2 = 254
Total Hosts/Subnet

130.191.3.3
AND
255.255.0.0/16 --> DSM
----------------
130.191.0.0/16 --> NA

130.191.11111111.0/24
130.191.255.0/24
--> Last unusable subnet = subnet 255

Last usable subnet = 130.191.254.0/24

255.255.255.0/24
--> CSM

Subnet Address <--> Broadcast Address <--> Host Range
0)130.191.0.0 <---> 130.191.0.255 <--> 130.191.0.1~130.191.0.254
1)130.191.1.0 <---> 130.191.1.255 <--> 130.191.1.1~130.191.1.254
2)130.191.2.0 <---> 130.191.2.255 <--> 130.191.2.1~130.191.2.254
3)130.191.3.0 <---> 130.191.3.255 <--> 130.191.3.1~130.191.3.254
4)130.191.4.0 <---> 130.191.4.255 <--> 130.191.4.1~130.191.4.254
5)130.191.5.0 <---> 130.191.5.255 <---> 130.191.5.1~130.191.5.254
6)130.191.6.0 <---> 130.191.6.255 <---> 130.191.6.1~130.191.6.254
7)130.191.7.0 <---> 130.191.7.255 <---> 130.191.7.1~130.191.7.254
*
*
*
254)130.191.254.0 <--> 130.191.254.255
255)130.191.255.0 <--> 130.191.255.255



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 150.150.0.0
Problem: 6 subnets

Solution:

::2^14 = 16,384-2 = 16,382
Total Network

::2^3 = 8-2 = 6
Total Subnets

::2^13 = 8192-2 = 8190
Total Hosts/Subnet

150.150.0.0
AND
255.255.0.0/16 --> DSM
------------------
150.150.0.0/16 --> NA

150.150.11100000.0/19
150.150.224.0/19
--> Last unusable subnet = subnet 7

150.150.192.0/19
--> Last usable subnet

255.255.224.0/19 --> Custom Subnet Mask


Subnet Address <---> Broadcast Address <---> Host Range
0)150.150.0.0 <-->150.150.31.255 <--> 150.150.0.1~150.150.21.254
1)150.150.32.0<->150.150.63.255<->150.150.32.1~150.150.63.254
2)150.150.64.0<->150.150.95.255<->150.150.64.1~150.150.95.254
3)150.150.96.0<->150.150.127.255<->150.150.96.1~150.150.127.254
4)150.150.128.0<->150.150.159.255<->150.150.128.1~150.150.159.254
5)150.150.160.0<->150.150.191.255<->150.150.160.1~150.150.191.254
6)150.150.192.0<->150.150.223.255<->150.150.192.1~150.150.223.254
7)150.150.224.0<-->150.150.255.255<-->UNUSABLE



########################################################################
########################################################################
########################################################################

Class C IP Address


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 200.133.175.0
Problem: 14 subnets

Solution:

::2^21 = 2,097,152-2 = 2,097,150
Total Network

::2^4 = 16-2 = 14
Total Subnets

::2^4 = 16-2 = 14
Total Hosts/Subnet


200.133.175.0
AND
255.255.255.0/24 --> DSM
--------------------
200.133.175.0/24 --> NA


200.133.175.11110000/28
200.133.175.240/28
--> Last unusable subnet = subnet 15


Last usable subnet:
-------------------------
200.133.175.224/28 --> Last usable subnet


255.255.255.240/28
--> CSM


Subnet Address <--> Broadcast Address <--> Host Range
0)200.133.175.0 <-> 200.133.175.15 <-> 200.133.175.1~200.133.175.14
1)200.133.175.16<->200.133.175.31<->200.133.175.17~200.133.175.30
2)200.133.175.32<->200.133.175.47<->200.133.175.33~200.133.175.46
3)200.133.175.48<->200.133.175.63<->200.133.175.49~200.133.175.62
4)200.133.175.64<->200.133.175.79<->200.133.175.65~200.133.175.78
5)200.133.175.80<->200.133.175.95<->200.133.175.81~200.133.175.94
6)200.133.175.96<->200.133.175.111<->200.133.175.97~200.133.175.110
7)200.133.175.112<->200.133.175.127<->200.133.175.113~200.133.175.126
8)200.133.175.128<->200.133.175.143<->200.133.175.129~200.133.175.142
9)200.133.175.144<->200.133.175.159<->200.133.175.145~200.133.175.158
10)200.133.175.160<->200.133.175.175<->200.133.175.161~200.133.175.174
11)200.133.175.176<->200.133.175.191<->200.133.175.177~200.133.175.190
12)200.133.175.192<->200.133.175.207<->200.133.175.193~200.133.175.206
13)200.133.175.208<->200.133.175.223<->200.133.175.209~200.133.175.222
14)200.133.175.224<->200.133.175.239<->200.133.175.225~200.133.175.238
15)200.133.175.240 <--> 200.133.175.255 <--> unusable


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Given: 207.5.3.56
Problem: 14 subnets

Solution:

::2^21 = 2,097,152-2 = 2,097,150
Total Network

::2^4 = 16-2 = 14
Total Subnet

::2^4 = 16-2 = 14
Total Hosts/Subnet

207.5.3.56
AND
255.255.255.0/24 --> DSM
------------------------
207.5.3.0/24 --> NA


207.5.3.11110000/28
207.5.3.240/28
--> Last unusable subnet = subnet 15


207.5.3.224/28
--> Last usable subnet


255.255.255.240/28 --> CSM


Subnet Address <--> Broadcast Address <--> Hosts Range
0)207.5.3.0 <-> 207.5.3.15 <->207.5.3.1~207.5.3.14
1)207.5.3.16<->207.5.3.31<->207.5.3.17~207.5.3.30
2)207.5.3.32<->207.5.3.47<->207.5.3.33~207.5.3.46
3)207.5.3.48<->207.5.3.63<->207.5.3.49~207.5.3.62
4)207.5.3.64<->207.5.3.79<->207.5.3.65~207.5.3.78
5)207.5.3.80<->207.5.3.95<->207.5.3.81~207.5.3.94
6)207.5.3.96<->207.5.3.111<->207.5.3.97~207.5.3.110
7)207.5.3.112<->207.5.3.127<->207.5.3.113~207.5.3.126
8)207.5.3.128<->207.5.3.143<->207.5.3.129~207.5.3.142
9)207.5.3.144<->207.5.3.159<->207.5.3.145~207.5.3.158
10)207.5.3.160<->207.5.3.175<->207.5.3.161~207.5.3.174
11)207.5.3.176<->207.5.3.191<->207.5.3.177~207.5.3.190
12)207.5.3.192<->207.5.3.207<->207.5.3.193~207.5.3.206
13)207.5.3.208<->207.5.3.223<->207.5.3.209~207.5.3.222
14)207.5.3.224<->207.5.3.239<->207.5.3.225~207.5.3.238
15)207.5.3.240<->207.5.3.255<---> unused