TCPクライアント側

Imports System.Net
Imports System.Text
Public Class Form1
    'サーバーのIPアドレス(または、ホスト名)とポート番号
    Dim strIpAddr As String = "localhost"
    Dim intPort As Integer = 60000

    'ソケット
    Dim mTcpClient As Sockets.TcpClient
    'ソケットストリーム
    Dim mNetStream As Sockets.NetworkStream
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'ソケット生成
        mTcpClient = New Sockets.TcpClient
        'ソケット接続
        mTcpClient.Connect(strIpAddr, intPort)
        'ソケットストリーム取得
        mNetStream = mTcpClient.GetStream()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        'ソケットクローズ
        mNetStream.Close()
        mTcpClient.Close()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Try
            '送信文字列をバイト配列変換
            Dim enc As Encoding = Encoding.GetEncoding("SHIFT-JIS")
            '最後尾にCR
            Dim data As Byte() = enc.GetBytes(Me.TextBox1.Text.Trim & ControlChars.Cr)
            Me.TextBox1.Text = ""

            'ソケット送信
            mNetStream.Write(data, 0, data.Count)

            'サーバからの応答を受信
            Dim bytRead As Byte() = New Byte(255) {}
            Dim intBytes As Integer = mNetStream.Read(bytRead, 0, bytRead.Length)

            '受信したデータを文字列に変換
            Dim resMsg As String = enc.GetString(bytRead, 0, intBytes)
            '末尾の\rを削除し表示
            Me.TextBox2.Text = resMsg.TrimEnd(ControlChars.Cr)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class

HTML+CSS

CSS::::::::::::::::

.category {
  width: 200px; /*全体の横幅*/
  border: 1px solid #333;
  font-size: 12px;
}

.category label {
    background: #333;
    color: #fff;
    padding: 12px;
    display: block;
    margin: 0;
    cursor: pointer;
    border-top: 1px solid #ccc;
}

.category label:first-child {
  border-top: none;
}

.category input.switch{
    display: none;
}

.category ul {
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -ms-transition: all 0.5s;
    -o-transition: all 0.5s;
    transition: all 0.5s;
    margin: 0;
    padding: 0;
    list-style: none;
}

.category li {
    border-top: 1px dashed #ddd;
    padding: 12px 8px 12px 24px;
}

.category li:first-child {
    border-top: none;
}

.category li:before {
    content: ">";
    font-size: 9px;
    font-weight: bold;
    color: #ccc;
    margin-right: 8px;
}

.category input.switch + ul{
    height: 240px; /*クリックして出てくる高さ*/
    overflow: hidden;
}

.category input.switch:not(:checked) + ul{
    height: 0;
}

.category input.switch:checked + ul{
    height: 240px; /*クリックして出てくる高さ*/
}

 

HMTL:::::::

<!DOCTYPE html>
<html lang="ja">
<head>
<link rel="stylesheet" href="style.css" type="text/css" media="screen,print" />
</head>
<body>
<div class="category">
    <label for="category-1">カテゴリー1</label>
    <input type="checkbox" id="category-1" class="switch" />
    <ul>
        <li><a href="">下カテゴリ</a></li>
        <li><a href="">下カテゴリ</a></li>
    </ul>
</div>
</body>
</html>

HTML+CSS

【HTML】

<ul class="gnav">
<li><a href="">メニュー1</a>
<ul>
  <li><a href="">サブメニュー1111</a></li>
  <li><a href="">サブメニュー2</a></li>
</ul>
</li>
<li><a href="">メニュー2</a></li>
</ul>

 

CSS

.gnav {
    display: block;
    height: 2rem;
    margin: 0 auto;
    width: 1000px;
}
.gnav > li {/*親階層のみ幅を25%にする*/
    width: 15%;
}
/*全てのリスト・リンク共通*/
.gnav li {
    list-style: none;
    position: relative;
}
.gnav li a {
    background: #001b34;
    border-right: 1px solid #eee;
    color: #fff;
    display: block;
    height: 2rem;
    line-height: 2rem;
    text-align: center;
    text-decoration: none;
    width: 100%;
}
/*子階層以降共通*/
.gnav li ul{
kist-style: none;
top: 100%;
left: 0;
margin: 0;
padding: 0;
border-radius: 0 0 3px 3px;
}
.gnav li li {
    height: 0;
    width:120%;
    overflow: hidden;
    transition: .5s;
}
.gnav li li a {
    border-top: 1px solid #eee;
}
.gnav li:hover > ul > li {
    height: 2rem;
    overflow: visible;
}

シリアル通信

' ============================================================================
' シリアル通信 サンプルプログラム
'
' <SerialCommunication.vb>
'
' Copyright (c) 2009 Servoland corporation.
' All rights reserved.
'
' 目的:
'        SerialPortクラスを用いたシリアル通信を行います。
'
' 注意:
'        使用時には実際のポート名(COM1,COM2など)および通信速度(bps)の設定を
'        行う必要があります。
'
' Version情報:                        -- 追加, 修正項目 --
'        Version 1.0        2009.08.19    : First construction.
'
' ============================================================================
Public Class SerialCommunication
    Dim TempStr As String ' 一時文字列

    Private Sub SerialCommunication_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With SerialPort1
            .PortName = "COM1"
            .BaudRate = 1200
            .DataBits = 8
            .Parity = IO.Ports.Parity.None
            .StopBits = IO.Ports.StopBits.One
            .ReceivedBytesThreshold = 1
        End With

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim value As Char
        Dim str As String
        value = e.KeyChar

        If value = vbCr Then
            str = TextBox1.Text.ToUpper() + vbCr
            If SerialPort1.IsOpen Then
                SerialPort1.Write(str)
            End If
            TextBox1.SelectAll()
        End If
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        If SerialPort1.IsOpen = False Then
            Try
                SerialPort1.Open()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "エラー", _
                    MessageBoxButtons.OK, _
                    MessageBoxIcon.Error, _
                    MessageBoxDefaultButton.Button3)
            End Try
        Else
            MessageBox.Show("既にシリアルポートを開いています。", "エラー", _
                MessageBoxButtons.OK, _
                MessageBoxIcon.Warning, _
                MessageBoxDefaultButton.Button3)

        End If
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        If SerialPort1.IsOpen = True Then
            SerialPort1.Close()
        End If
    End Sub

    Private Sub SerialCommunication_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        If SerialPort1.IsOpen = True Then
            SerialPort1.Close()
        End If
    End Sub

    Delegate Sub RecvDataDelegate(ByVal RecvStr As String)

    Private Sub RecvData(ByVal RecvStr As String)
        ' 受信欄更新
        TextBox2.Text = RecvStr

        ' 受信履歴更新
        RichTextBox1.Text = RichTextBox1.Text + RecvStr + vbCr

        ' 受信履歴の最下行表示
        RichTextBox1.SelectionStart = RichTextBox1.Text.Length - 1
        RichTextBox1.ScrollToCaret()
    End Sub

    Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Dim Recv As New RecvDataDelegate(AddressOf RecvData)
        Dim strReceived As String

        Try
            ' 受信データ読込
            strReceived = SerialPort1.ReadExisting()

            ' 受信文字列結合
            TempStr = TempStr + strReceived

            ' CR受信(受信完了)
            If strReceived(strReceived.Length - 1) = vbCr Then
                ' CR削除
                TempStr = TempStr.Remove(TempStr.Length - 1, 1)

                ' TextBox1からInvoke
                TextBox1.Invoke(Recv, TempStr)

                ' 一時文字列初期化
                TempStr = ""
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, "受信エラー", _
                MessageBoxButtons.OK, _
                MessageBoxIcon.Error, _
                MessageBoxDefaultButton.Button3)
        End Try

    End Sub

End Class

シリアル通信プログラム

Public Class SerialCommunication
    Dim TempStr As String ' 一時文字列

    Private Sub SerialCommunication_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With SerialPort1
            .PortName = "COM1"
            .BaudRate = 1200
            .DataBits = 8
            .Parity = IO.Ports.Parity.None
            .StopBits = IO.Ports.StopBits.One
            .ReceivedBytesThreshold = 1
        End With

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim value As Char
        Dim str As String
        value = e.KeyChar

        If value = vbCr Then
            str = TextBox1.Text.ToUpper() + vbCr
            If SerialPort1.IsOpen Then
                SerialPort1.Write(str)
            End If
            TextBox1.SelectAll()
        End If
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        If SerialPort1.IsOpen = False Then
            Try
                SerialPort1.Open()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "エラー", _
                    MessageBoxButtons.OK, _
                    MessageBoxIcon.Error, _
                    MessageBoxDefaultButton.Button3)
            End Try
        Else
            MessageBox.Show("既にシリアルポートを開いています。", "エラー", _
                MessageBoxButtons.OK, _
                MessageBoxIcon.Warning, _
                MessageBoxDefaultButton.Button3)

        End If
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        If SerialPort1.IsOpen = True Then
            SerialPort1.Close()
        End If
    End Sub

    Private Sub SerialCommunication_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        If SerialPort1.IsOpen = True Then
            SerialPort1.Close()
        End If
    End Sub

    Delegate Sub RecvDataDelegate(ByVal RecvStr As String)

    Private Sub RecvData(ByVal RecvStr As String)
        ' 受信欄更新
        TextBox2.Text = RecvStr

        ' 受信履歴更新
        RichTextBox1.Text = RichTextBox1.Text + RecvStr + vbCr

        ' 受信履歴の最下行表示
        RichTextBox1.SelectionStart = RichTextBox1.Text.Length - 1
        RichTextBox1.ScrollToCaret()
    End Sub

    Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Dim Recv As New RecvDataDelegate(AddressOf RecvData)
        Dim strReceived As String

        Try
            ' 受信データ読込
            strReceived = SerialPort1.ReadExisting()

            ' 受信文字列結合
            TempStr = TempStr + strReceived

            ' CR受信(受信完了)
            If strReceived(strReceived.Length - 1) = vbCr Then
                ' CR削除
                TempStr = TempStr.Remove(TempStr.Length - 1, 1)

                ' TextBox1からInvoke
                TextBox1.Invoke(Recv, TempStr)

                ' 一時文字列初期化
                TempStr = ""
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, "受信エラー", _
                MessageBoxButtons.OK, _
                MessageBoxIcon.Error, _
                MessageBoxDefaultButton.Button3)
        End Try

    End Sub

End Class

   Public b8_flag As Integer = 0

    Dim startTime As DateTime
    Dim ts As TimeSpan

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

        Dim startDt As DateTime = DateTime.Now

        If b8_flag = 0 Then
            Button8.Text = "測定停止"

            With ToolStripStatusLabel1
                .Text = "測定中"
                .BackColor = Color.Yellow
            End With
            ToolStripStatusLabel2.Text = "測定時間:00:00:00"
            startTime = DateTime.Now
            Threading.Thread.Sleep(100)
            Timer2.Start()

            b8_flag = 1
        Else
            With ToolStripStatusLabel1
                .Text = "測定停止"
                .BackColor = SystemColors.Control
            End With

            sw.Stop()

            Timer2.Enabled = False
            'ToolStripStatusLabel2.Text = "測定時間:00:00:00"

            b8_flag = 0
        End If
    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        ToolStripStatusLabel2.Text = "測定時間:" & sw.Elapsed.Hours.ToString("00") & ":" & sw.Elapsed.Minutes.ToString("00") & ":" & sw.Elapsed.Seconds.ToString("00")
        ts = Now.Subtract(startTime)    ' 経過時間算出
        ToolStripStatusLabel4.Text = "経過時間:" & ts.TotalMinutes.ToString

        ts = DateTime.Now - startTime
        ToolStripStatusLabel4.Text = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds)

    End Sub