
Imports RedCrabApi


Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        AddHandler rc.RedCrabTransfer, AddressOf Transfer
        AddHandler rc.PipeInfo, AddressOf Info

    End Sub

    Dim rc As New NamedPipeClient(1)

    Private Sub Transfer(sender As Object, e As RedCrabApi.RedCrabEventArgs)

        If e.DataType = RedCrabDataType.Double Then
            Dim d As Double
            d = e.Data
            If (e.Command = "square") Then
                rc.Write(d * d)
            Else
                rc.Write(d * 2)
            End If
        Else
            rc.Write("Error:" & e.DataType.ToString())
        End If

    End Sub

    Private Sub Info(sender As Object, e As RedCrabEventArgs)
        TextBox1.Text = TextBox1.Text & vbCrLf & e.Message
    End Sub

End Class