0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

IPとサブネットマスクからネットワークIDとブロードキャストアドレスを算出

Posted at

概要

タイトルまんま
罵らないで!VB簡単で大好き!

コード


Module Module1

	Sub Main()
		Dim ip As String = "192.180.14.200"
		Dim mask As String = "255.192.0.0"

		Dim ip_sp(3) As String
		ip_sp = ip.Split(".")
		Dim mask_sp(3) As String
		mask_sp = mask.Split(".")



		Dim ip_byte(3) As Byte
		Dim mask_byte(3) As Byte

		For i = 0 To 3
			ip_byte(i) = Convert.ToByte(ip_sp(i))
			mask_byte(i) = Convert.ToByte(mask_sp(i))
		Next



		Dim start_byte(3) As Byte

		For i = 0 To 3
			start_byte(i) = ip_byte(i) And mask_byte(i)
		Next



		Dim end_byte(3) As Byte

		For i = 0 To 3
			end_byte(i) = Not mask_byte(i) Xor start_byte(i)
		Next


		For i = 0 To 3
			Console.Write(start_byte(i).ToString)
			Console.Write(".")
		Next

		Console.WriteLine()

		For i = 0 To 3
			Console.Write(end_byte(i).ToString)
			Console.Write(".")
		Next

		Console.WriteLine()

	End Sub

End Module


192.128.0.0.
192.191.255.255.
続行するには何かキーを押してください . . .

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?