Option Strict Off
Option Explicit On

Friend Class vbafrm
	Inherits System.Windows.Forms.Form
    Private Sub Compute_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Compute.Click
        ' Mixed language, PPP DLL utilizes 32 bit representation
        ' for integer and double types, VB 2008 does the same
        ' with different languages you MUST CHECK this
        Dim Stream As Integer, um As Integer, res As Integer
        Dim p As Double, t As Double
        ' put the stream's reference
        Stream = CInt(EdStream.Text)
        ' test stream's data validity
        If isSDef(Stream) Then

            ' stop Error messages
            Call defErrMsg(False)
            ' reset Err's flag
            Call setErrFlag(False)
            ' get operating conditions
            t = CDbl(ShowT.Text)
            p = CDbl(ShowP.Text)
            ' set units (if not defined)
            um = 17 ' UM code for temperature
            ShowTUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            um = 15 ' UM code for pressure
            ShowPUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ' isothermal flash at desired p,t conditions
            res = setOp(Stream, t, p)
            If (res = 0) Then GoTo err_Renamed
            ' get all properties
            ShowLF.Text = CStr(StrLf(Stream))
            ShowGF.Text = CStr(1.0 - StrLf(Stream))
            ShowLD.Text = CStr(StrLD(Stream))
            ShowGD.Text = CStr(StrGD(Stream))
            um = 27 ' UM code for density
            ShowDUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLV.Text = CStr(StrLV(Stream))
            ShowGV.Text = CStr(StrGV(Stream))
            um = 32 ' UM code for viscosity
            ShowVUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLC.Text = CStr(StrLC(Stream))
            ShowGC.Text = CStr(StrGC(Stream))
            um = 31 ' UM code for thermal conductivity
            ShowCUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLS.Text = CStr(StrLSS(Stream))
            ShowGS.Text = CStr(StrGSS(Stream))
            um = 38 ' UM code for velocity
            ShowSUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLJ.Text = CStr(StrLJT(Stream))
            ShowGJ.Text = CStr(StrGJT(Stream))
            um = 52 ' UM code for Joule Thomson
            ShowJUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLCP.Text = CStr(StrLCp(Stream))
            ShowGCP.Text = CStr(StrGCp(Stream))
            um = 23 ' UM code for heat capacity
            ShowCPUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ShowLCV.Text = CStr(StrLCv(Stream))
            ShowGCV.Text = CStr(StrGCv(Stream))
            um = 23 ' UM code for heat capacity
            ShowCVUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
            ' show the Err message (if present)
            ' (get Err flag, if TRUE there is
            '  an Err message)
err_Renamed:
            If (getErrFlag()) Then
                ErrMsgBox.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ErrMsg())
            Else
                ErrMsgBox.Text = "No Errors"
            End If
        End If

    End Sub

    Private Sub Editor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Editor.Click
        Dim um As Long
        ' call Prode Properties Editor
        Call edS(1)
        ' initialize values to avoid errors
        ShowP.Text = CStr(getPatm())
        ShowT.Text = CStr(100.0)
        ' set units (may have been modified)
        ' remaining units will be updated when showing results
        um = 17 ' UM code for temperature
        ShowTUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
        um = 15 ' UM code for pressure
        ShowPUM.Text = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(getSUMS(um))
    End Sub
End Class