
Sub cmdDone_Click ()
    Dim buf As DataBuffer
    Dim Length As Long
    buf.Code = 3
    retcode = UnloadDosAp(DosAp, buf, Len(buf))
    If (retcode <> 0) Then
        ErrorMessage (retcode)
    End If
    Unload Form1
    End
End Sub

Sub Form_Load ()
   retcode = LoadDosAp("ctof3.exe", DosAp, SW_SHOWMINIMIZED, 1024)
'    retcode = DebugDosAp("cv386", "d:\pharlapx\examples\ctof\ctof3.exe", DosAp,1024)
    If (retcode <> 0) Then
        ErrorMessage (retcode)
        End
    End If
End Sub

Sub txtDegC_KeyPress (KeyAscii As Integer)
Dim DataBuf As DataBuffer
Dim Length As Long
    If (KeyAscii = 13) Then
        DataBuf.Code = 1
        DataBuf.ReturnValue = Val(txtDegC.Text)
        retcode = SendToDos(DosAp, DataBuf, Len(DataBuf))
        If (retcode <> 0) Then
            ErrorMessage (retcode)
        Else
            retcode = GetFromDos(DosAp, DataBuf, Len(DataBuf), Length)
            If (retcode <> 0) Or (Length > BufferSize) Then
                ErrorMessage (retcode)
            Else
                txtDegF.Text = DataBuf.ReturnValue
            End If
        End If
    End If
End Sub

Sub txtDegF_KeyPress (KeyAscii As Integer)
Dim DataBuf As DataBuffer
Dim Length As Long
    If (KeyAscii = 13) Then
        DataBuf.Code = 2
        DataBuf.ReturnValue = Val(txtDegF.Text)
        retcode = SendToDos(DosAp, DataBuf, Len(DataBuf))
        If (retcode <> 0) Then
            ErrorMessage (retcode)
        Else
            retcode = GetFromDos(DosAp, DataBuf, Len(DataBuf), Length)
            If (retcode <> 0) Or (Length > BufferSize) Then
                ErrorMessage (retcode)
            Else
                txtDegC.Text = DataBuf.ReturnValue
            End If
        End If
    End If
End Sub

