Vb6 to C# .Perform Functionality in C#












0












$begingroup$


Private Sub btnCalculate_Click()
{
Calculations
With crlReport
.ReportFileName = App.Path & "Output.rpt"
.Action = 1
End With
End Sub



Private Sub Calculations()
'On Error Resume Next
Dim strRead, strFatigue, strInsert, strDelete, strMaterial As String
Dim Sf, Re, ModElasticity, MaxWorkStress, StrouhalNum, MatDensity, Ns, fs, Ro, Haf, Da, Ros, Has1, Has2, Has, I, M, Fa1, Fa, Hf1, Hf2, Hf, Fn, Hc, Fnc As Double
Dim Delta, Nsc1, Nsc2, Nsc3, Nsc, Vir, Gsp1, Gsp2, Gsp3, Gsp, Pd, Sd, ABRatio, Kt, Somax, Ft, FtFeSf, Sr, St1, St2, St, Sa, Pd1, Sd1, Smax, LHS, RHS As Double
Dim r, Fm, r1, Fm1, Pd2, Pt, Sd2, St3, Smax1, FtFeSf1, Pc, Pt1 As Double

Set recRead = New ADODB.Recordset
Set recFatigue = New ADODB.Recordset
Set recInsert = New ADODB.Recordset
Set recDelete = New ADODB.Recordset
Set recMaterial = New ADODB.Recordset

If recRead.State = 1 Then recRead.Close
strRead = "select * from Simplex order by SNO"
recRead.Open strRead, conThermowell, adOpenDynamic, adLockPessimistic

If recDelete.State = 1 Then recDelete.Close
strDelete = "Truncate table OutputRes"
recDelete.Open strDelete, conThermowell, adOpenDynamic, adLockPessimistic

Do While Not (recRead.EOF)
If recFatigue.State = 1 Then recFatigue.Close
strFatigue = "select value from Fatigue where FatigueID='" & Trim(recRead(21)) & "'"
recFatigue.Open strFatigue, conThermowell, adOpenDynamic, adLockPessimistic

MatDensity = 0.22
Ros = 169
Ro = 0.499
Delta = 0.0005
Ft = 0.9386
Sf = 0
Re = 0
E = 0
S = 0
Rom = 0
ModElasticity = 0
MaxWorkStress = 0
StrouhalNum = 0
Ns = 0
fs = 0
Haf = 0
Da = 0
Has = 0
M = 0
Fa = 0
Hf = 0
Fn = 0
Hc = 0
Fnc = 0
Nsc = 0
Vir = 0
Gsp = 0
Pd = 0
Sd = 0
ABRatio = 0
Kt = 0
Somax = 0
FtFeSf = 0
Sr = 0
St = 0
Sa = 0
Pd1 = 0
Sd1 = 0
Smax = 0
LHS = 0
RHS = 0
r = 0
Fm = 0
r1 = 0
Fm1 = 0
Pd2 = 0
Pt = 0
Sd2 = 0
St3 = 0
Smax1 = 0
FtFeSf1 = 0
Pc = 0
Pt1 = 0

Call Modulous(recRead(4), recRead(5))
Call Stress(recRead(4), recRead(5))
Call SpecificWeight(recRead(4), recRead(5))

Sf = recFatigue(0)
Re = (recReadZ(7) * recRead(17) * recRead(9)) / (recRead(10) * 6.7197 * 0.0001 * 12)

ModElasticity = 0.22 * (1 - (22 / Re))
MaxWorkStress = 0.213 - 0.0248 * Math.Log((Re / 1300) ^ 2) / Math.Log(10) + 0.0095 * Math.Log((Re / 1300) ^ 3) / Math.Log(10)

If Re > 21.999 And Re < 1300 Then
StrouhalNum = ModElasticity
ElseIf Re > 1299.9999 And Re < 500000 Then
StrouhalNum = MaxWorkStress
Else
StrouhalNum = MatDensity
End If

Ns = StrouhalNum

fs = Ns * 12 * (recRead(7) / recRead(17))

Haf = 1 - ((Ro) / (2 * Rom * 1728))

If recRead(11) = 1 Then
Da = (recRead(16) + recRead(17)) / 2
Else
Da = recRead(16)
End If

Has1 = (Ros) / (2 * Rom * 1728)
Has2 = 1 / (((Da / recRead(15)) ^ 2) - 1)
Has = 1 - (Has1 * Has2)

I = 3.14 * (Da ^ 4 - recRead(15) ^ 4) / 64

M = Rom * 3.14 * (Da ^ 2 - recRead(15) ^ 2) / 4

Fa1 = ((1.875 ^ 2) / 6.28) * (((E * I * 386.088) / M) ^ 0.5)
Fa = Fa1 / (recRead(12) ^ 2)

Hf1 = 0.99 * (1 + (1 - (recRead(17) / recRead(16))) + ((1 - (recRead(17) / recRead(16))) ^ 2))
Hf2 = 1 + 1.1 * ((Da / recRead(12)) ^ (3 * (1 - 0.8 * (recRead(15) / Da))))
Hf = Hf1 / Hf2

Fn = Hf * Fa * Haf * Has

Hc = 1 - (0.61 * (recRead(16) / recRead(12)))

Fnc = Hc * Fn

Nsc1 = (3.14 ^ 2) * Delta
Nsc2 = Rom / ((Ro * 5.787 * (10 ^ -4)))
Nsc3 = 1 - (recRead(15) / recRead(17)) ^ 2
Nsc = Nsc1 * Nsc2 * Nsc3

Vir = (recRead(17) / 12 * Fnc) / (2 * Ns)

Gsp1 = 16 * (recRead(12) ^ 2)
Gsp2 = (3 * 3.14 * (recRead(16) ^ 2)) * (1 - (recRead(15) / recRead(16)) ^ 4)
Gsp3 = 1 + 2 * (recRead(17) / recRead(16))
Gsp = (Gsp1 * Gsp3) / Gsp2

Pd = (0.5 * Ro * 5.787 * 10 ^ -4 * Vir ^ 2 * 0.1 * 12 ^ 2) / 386.088

Sd = Gsp * Pd * 1000

ABRatio = recRead(16) / recRead(17)

If ABRatio > 1.2992 Then
Kt = 2.2
Else
Kt = 1.1 + 0.033 * ABRatio
End If

Somax = Kt * Sd

FtFeSf = Ft * Sf

Sr = recRead(6)

St1 = 1 + (recRead(15) / recRead(16)) ^ 2
St2 = 1 - (recRead(15) / recRead(16)) ^ 2
St = Sr * (St1 / St2)

Sa = Sr / St2

Pd1 = (0.5 * Ro * 5.787 * 10 ^ -4 * 1.4 * (recRead(7) ^ 2) * 12 ^ 2) / 386.088

Sd1 = Gsp * Pd1

Smax = Sd1 + Sa

LHS = Sqr(((Smax - Sr) ^ 2 + (Smax - St) ^ 2 + (St - Sr) ^ 2) / 2)

RHS = 1.5 * S

r = fs / Fnc

Fm = 1 / (1 - (r ^ 2))

r1 = 2 * r

Fm1 = 1 / (1 - (r1 ^ 2))

Pd2 = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 0.1) / 386.088

Pt = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 1) / 386.088

Sd2 = Fm1 * Pd2 * Gsp

St3 = Gsp * Fm * Pt

Smax1 = 2.2 * ((Sd2 ^ 2 + St3 ^ 2) ^ 0.5)

FtFeSf1 = Ft * Sf

Pc = (0.66 * S) * (2.167 / ((2 * recRead(17)) / (recRead(17) - recRead(15)))) - 0.0833

Pt1 = (S / 0.13) * (recRead(18) / recRead(15)) ^ 2

If recMaterial.State = 1 Then recMaterial.Close
strMaterial = "select MatDesc from Materials where [ID]='" & recRead(4) & "'"
recMaterial.Open strMaterial, conThermowell, adOpenDynamic, adLockPessimistic

If recInsert.State = 1 Then recInsert.Close
strInsert = "insert into OutputRes values ('" & recRead(1) & "','" & recRead(2) & "','" & recRead(3) & "','" & recMaterial(0) & "'," & _
"" & recRead(5) & "," & recRead(6) & "," & recRead(7) & "," & recRead(8) & "," & recRead(9) & "," & recRead(10) & "," & recRead(11) & "," & _
"" & recRead(12) & "," & recRead(13) & "," & recRead(14) & "," & recRead(15) & "," & recRead(16) & "," & recRead(17) & "," & recRead(18) & "," & _
"" & recRead(19) & "," & recRead(20) & ",'" & recRead(21) & "','" & recRead(22) & "','" & recRead(23) & "'," & Sf & "," & Re & "," & E & "," & S & "," & Rom & "," & _
"" & ModElasticity & "," & MaxWorkStress & "," & StrouhalNum & "," & Ns & "," & fs & "," & Haf & "," & Da & "," & Has & "," & _
"" & M & "," & Fa & "," & Hf & "," & Fn & "," & Hc & "," & Fnc & "," & Nsc & "," & Vir & "," & Gsp & "," & Pd & "," & Sd & "," & _
"" & ABRatio & "," & Kt & "," & Somax & "," & FtFeSf & "," & Sr & "," & St & "," & Sa & "," & Pd1 & "," & Sd1 & "," & Smax & "," & _
"" & LHS & "," & RHS & "," & r & "," & Fm & "," & r1 & "," & Fm1 & "," & Pd2 & "," & Pt & "," & Sd2 & "," & St3 & "," & Smax1 & "," & _
"" & FtFeSf1 & "," & MatDensity & "," & Ro & "," & Ros & "," & Delta & "," & Ft & "," & Pc & "," & Pt1 & ")"
recInsert.Open strInsert, conThermowell, adOpenDynamic, adLockPessimistic

recRead.MoveNext
Loop
End Sub








share







New contributor




user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$

















    0












    $begingroup$


    Private Sub btnCalculate_Click()
    {
    Calculations
    With crlReport
    .ReportFileName = App.Path & "Output.rpt"
    .Action = 1
    End With
    End Sub



    Private Sub Calculations()
    'On Error Resume Next
    Dim strRead, strFatigue, strInsert, strDelete, strMaterial As String
    Dim Sf, Re, ModElasticity, MaxWorkStress, StrouhalNum, MatDensity, Ns, fs, Ro, Haf, Da, Ros, Has1, Has2, Has, I, M, Fa1, Fa, Hf1, Hf2, Hf, Fn, Hc, Fnc As Double
    Dim Delta, Nsc1, Nsc2, Nsc3, Nsc, Vir, Gsp1, Gsp2, Gsp3, Gsp, Pd, Sd, ABRatio, Kt, Somax, Ft, FtFeSf, Sr, St1, St2, St, Sa, Pd1, Sd1, Smax, LHS, RHS As Double
    Dim r, Fm, r1, Fm1, Pd2, Pt, Sd2, St3, Smax1, FtFeSf1, Pc, Pt1 As Double

    Set recRead = New ADODB.Recordset
    Set recFatigue = New ADODB.Recordset
    Set recInsert = New ADODB.Recordset
    Set recDelete = New ADODB.Recordset
    Set recMaterial = New ADODB.Recordset

    If recRead.State = 1 Then recRead.Close
    strRead = "select * from Simplex order by SNO"
    recRead.Open strRead, conThermowell, adOpenDynamic, adLockPessimistic

    If recDelete.State = 1 Then recDelete.Close
    strDelete = "Truncate table OutputRes"
    recDelete.Open strDelete, conThermowell, adOpenDynamic, adLockPessimistic

    Do While Not (recRead.EOF)
    If recFatigue.State = 1 Then recFatigue.Close
    strFatigue = "select value from Fatigue where FatigueID='" & Trim(recRead(21)) & "'"
    recFatigue.Open strFatigue, conThermowell, adOpenDynamic, adLockPessimistic

    MatDensity = 0.22
    Ros = 169
    Ro = 0.499
    Delta = 0.0005
    Ft = 0.9386
    Sf = 0
    Re = 0
    E = 0
    S = 0
    Rom = 0
    ModElasticity = 0
    MaxWorkStress = 0
    StrouhalNum = 0
    Ns = 0
    fs = 0
    Haf = 0
    Da = 0
    Has = 0
    M = 0
    Fa = 0
    Hf = 0
    Fn = 0
    Hc = 0
    Fnc = 0
    Nsc = 0
    Vir = 0
    Gsp = 0
    Pd = 0
    Sd = 0
    ABRatio = 0
    Kt = 0
    Somax = 0
    FtFeSf = 0
    Sr = 0
    St = 0
    Sa = 0
    Pd1 = 0
    Sd1 = 0
    Smax = 0
    LHS = 0
    RHS = 0
    r = 0
    Fm = 0
    r1 = 0
    Fm1 = 0
    Pd2 = 0
    Pt = 0
    Sd2 = 0
    St3 = 0
    Smax1 = 0
    FtFeSf1 = 0
    Pc = 0
    Pt1 = 0

    Call Modulous(recRead(4), recRead(5))
    Call Stress(recRead(4), recRead(5))
    Call SpecificWeight(recRead(4), recRead(5))

    Sf = recFatigue(0)
    Re = (recReadZ(7) * recRead(17) * recRead(9)) / (recRead(10) * 6.7197 * 0.0001 * 12)

    ModElasticity = 0.22 * (1 - (22 / Re))
    MaxWorkStress = 0.213 - 0.0248 * Math.Log((Re / 1300) ^ 2) / Math.Log(10) + 0.0095 * Math.Log((Re / 1300) ^ 3) / Math.Log(10)

    If Re > 21.999 And Re < 1300 Then
    StrouhalNum = ModElasticity
    ElseIf Re > 1299.9999 And Re < 500000 Then
    StrouhalNum = MaxWorkStress
    Else
    StrouhalNum = MatDensity
    End If

    Ns = StrouhalNum

    fs = Ns * 12 * (recRead(7) / recRead(17))

    Haf = 1 - ((Ro) / (2 * Rom * 1728))

    If recRead(11) = 1 Then
    Da = (recRead(16) + recRead(17)) / 2
    Else
    Da = recRead(16)
    End If

    Has1 = (Ros) / (2 * Rom * 1728)
    Has2 = 1 / (((Da / recRead(15)) ^ 2) - 1)
    Has = 1 - (Has1 * Has2)

    I = 3.14 * (Da ^ 4 - recRead(15) ^ 4) / 64

    M = Rom * 3.14 * (Da ^ 2 - recRead(15) ^ 2) / 4

    Fa1 = ((1.875 ^ 2) / 6.28) * (((E * I * 386.088) / M) ^ 0.5)
    Fa = Fa1 / (recRead(12) ^ 2)

    Hf1 = 0.99 * (1 + (1 - (recRead(17) / recRead(16))) + ((1 - (recRead(17) / recRead(16))) ^ 2))
    Hf2 = 1 + 1.1 * ((Da / recRead(12)) ^ (3 * (1 - 0.8 * (recRead(15) / Da))))
    Hf = Hf1 / Hf2

    Fn = Hf * Fa * Haf * Has

    Hc = 1 - (0.61 * (recRead(16) / recRead(12)))

    Fnc = Hc * Fn

    Nsc1 = (3.14 ^ 2) * Delta
    Nsc2 = Rom / ((Ro * 5.787 * (10 ^ -4)))
    Nsc3 = 1 - (recRead(15) / recRead(17)) ^ 2
    Nsc = Nsc1 * Nsc2 * Nsc3

    Vir = (recRead(17) / 12 * Fnc) / (2 * Ns)

    Gsp1 = 16 * (recRead(12) ^ 2)
    Gsp2 = (3 * 3.14 * (recRead(16) ^ 2)) * (1 - (recRead(15) / recRead(16)) ^ 4)
    Gsp3 = 1 + 2 * (recRead(17) / recRead(16))
    Gsp = (Gsp1 * Gsp3) / Gsp2

    Pd = (0.5 * Ro * 5.787 * 10 ^ -4 * Vir ^ 2 * 0.1 * 12 ^ 2) / 386.088

    Sd = Gsp * Pd * 1000

    ABRatio = recRead(16) / recRead(17)

    If ABRatio > 1.2992 Then
    Kt = 2.2
    Else
    Kt = 1.1 + 0.033 * ABRatio
    End If

    Somax = Kt * Sd

    FtFeSf = Ft * Sf

    Sr = recRead(6)

    St1 = 1 + (recRead(15) / recRead(16)) ^ 2
    St2 = 1 - (recRead(15) / recRead(16)) ^ 2
    St = Sr * (St1 / St2)

    Sa = Sr / St2

    Pd1 = (0.5 * Ro * 5.787 * 10 ^ -4 * 1.4 * (recRead(7) ^ 2) * 12 ^ 2) / 386.088

    Sd1 = Gsp * Pd1

    Smax = Sd1 + Sa

    LHS = Sqr(((Smax - Sr) ^ 2 + (Smax - St) ^ 2 + (St - Sr) ^ 2) / 2)

    RHS = 1.5 * S

    r = fs / Fnc

    Fm = 1 / (1 - (r ^ 2))

    r1 = 2 * r

    Fm1 = 1 / (1 - (r1 ^ 2))

    Pd2 = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 0.1) / 386.088

    Pt = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 1) / 386.088

    Sd2 = Fm1 * Pd2 * Gsp

    St3 = Gsp * Fm * Pt

    Smax1 = 2.2 * ((Sd2 ^ 2 + St3 ^ 2) ^ 0.5)

    FtFeSf1 = Ft * Sf

    Pc = (0.66 * S) * (2.167 / ((2 * recRead(17)) / (recRead(17) - recRead(15)))) - 0.0833

    Pt1 = (S / 0.13) * (recRead(18) / recRead(15)) ^ 2

    If recMaterial.State = 1 Then recMaterial.Close
    strMaterial = "select MatDesc from Materials where [ID]='" & recRead(4) & "'"
    recMaterial.Open strMaterial, conThermowell, adOpenDynamic, adLockPessimistic

    If recInsert.State = 1 Then recInsert.Close
    strInsert = "insert into OutputRes values ('" & recRead(1) & "','" & recRead(2) & "','" & recRead(3) & "','" & recMaterial(0) & "'," & _
    "" & recRead(5) & "," & recRead(6) & "," & recRead(7) & "," & recRead(8) & "," & recRead(9) & "," & recRead(10) & "," & recRead(11) & "," & _
    "" & recRead(12) & "," & recRead(13) & "," & recRead(14) & "," & recRead(15) & "," & recRead(16) & "," & recRead(17) & "," & recRead(18) & "," & _
    "" & recRead(19) & "," & recRead(20) & ",'" & recRead(21) & "','" & recRead(22) & "','" & recRead(23) & "'," & Sf & "," & Re & "," & E & "," & S & "," & Rom & "," & _
    "" & ModElasticity & "," & MaxWorkStress & "," & StrouhalNum & "," & Ns & "," & fs & "," & Haf & "," & Da & "," & Has & "," & _
    "" & M & "," & Fa & "," & Hf & "," & Fn & "," & Hc & "," & Fnc & "," & Nsc & "," & Vir & "," & Gsp & "," & Pd & "," & Sd & "," & _
    "" & ABRatio & "," & Kt & "," & Somax & "," & FtFeSf & "," & Sr & "," & St & "," & Sa & "," & Pd1 & "," & Sd1 & "," & Smax & "," & _
    "" & LHS & "," & RHS & "," & r & "," & Fm & "," & r1 & "," & Fm1 & "," & Pd2 & "," & Pt & "," & Sd2 & "," & St3 & "," & Smax1 & "," & _
    "" & FtFeSf1 & "," & MatDensity & "," & Ro & "," & Ros & "," & Delta & "," & Ft & "," & Pc & "," & Pt1 & ")"
    recInsert.Open strInsert, conThermowell, adOpenDynamic, adLockPessimistic

    recRead.MoveNext
    Loop
    End Sub








    share







    New contributor




    user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$















      0












      0








      0





      $begingroup$


      Private Sub btnCalculate_Click()
      {
      Calculations
      With crlReport
      .ReportFileName = App.Path & "Output.rpt"
      .Action = 1
      End With
      End Sub



      Private Sub Calculations()
      'On Error Resume Next
      Dim strRead, strFatigue, strInsert, strDelete, strMaterial As String
      Dim Sf, Re, ModElasticity, MaxWorkStress, StrouhalNum, MatDensity, Ns, fs, Ro, Haf, Da, Ros, Has1, Has2, Has, I, M, Fa1, Fa, Hf1, Hf2, Hf, Fn, Hc, Fnc As Double
      Dim Delta, Nsc1, Nsc2, Nsc3, Nsc, Vir, Gsp1, Gsp2, Gsp3, Gsp, Pd, Sd, ABRatio, Kt, Somax, Ft, FtFeSf, Sr, St1, St2, St, Sa, Pd1, Sd1, Smax, LHS, RHS As Double
      Dim r, Fm, r1, Fm1, Pd2, Pt, Sd2, St3, Smax1, FtFeSf1, Pc, Pt1 As Double

      Set recRead = New ADODB.Recordset
      Set recFatigue = New ADODB.Recordset
      Set recInsert = New ADODB.Recordset
      Set recDelete = New ADODB.Recordset
      Set recMaterial = New ADODB.Recordset

      If recRead.State = 1 Then recRead.Close
      strRead = "select * from Simplex order by SNO"
      recRead.Open strRead, conThermowell, adOpenDynamic, adLockPessimistic

      If recDelete.State = 1 Then recDelete.Close
      strDelete = "Truncate table OutputRes"
      recDelete.Open strDelete, conThermowell, adOpenDynamic, adLockPessimistic

      Do While Not (recRead.EOF)
      If recFatigue.State = 1 Then recFatigue.Close
      strFatigue = "select value from Fatigue where FatigueID='" & Trim(recRead(21)) & "'"
      recFatigue.Open strFatigue, conThermowell, adOpenDynamic, adLockPessimistic

      MatDensity = 0.22
      Ros = 169
      Ro = 0.499
      Delta = 0.0005
      Ft = 0.9386
      Sf = 0
      Re = 0
      E = 0
      S = 0
      Rom = 0
      ModElasticity = 0
      MaxWorkStress = 0
      StrouhalNum = 0
      Ns = 0
      fs = 0
      Haf = 0
      Da = 0
      Has = 0
      M = 0
      Fa = 0
      Hf = 0
      Fn = 0
      Hc = 0
      Fnc = 0
      Nsc = 0
      Vir = 0
      Gsp = 0
      Pd = 0
      Sd = 0
      ABRatio = 0
      Kt = 0
      Somax = 0
      FtFeSf = 0
      Sr = 0
      St = 0
      Sa = 0
      Pd1 = 0
      Sd1 = 0
      Smax = 0
      LHS = 0
      RHS = 0
      r = 0
      Fm = 0
      r1 = 0
      Fm1 = 0
      Pd2 = 0
      Pt = 0
      Sd2 = 0
      St3 = 0
      Smax1 = 0
      FtFeSf1 = 0
      Pc = 0
      Pt1 = 0

      Call Modulous(recRead(4), recRead(5))
      Call Stress(recRead(4), recRead(5))
      Call SpecificWeight(recRead(4), recRead(5))

      Sf = recFatigue(0)
      Re = (recReadZ(7) * recRead(17) * recRead(9)) / (recRead(10) * 6.7197 * 0.0001 * 12)

      ModElasticity = 0.22 * (1 - (22 / Re))
      MaxWorkStress = 0.213 - 0.0248 * Math.Log((Re / 1300) ^ 2) / Math.Log(10) + 0.0095 * Math.Log((Re / 1300) ^ 3) / Math.Log(10)

      If Re > 21.999 And Re < 1300 Then
      StrouhalNum = ModElasticity
      ElseIf Re > 1299.9999 And Re < 500000 Then
      StrouhalNum = MaxWorkStress
      Else
      StrouhalNum = MatDensity
      End If

      Ns = StrouhalNum

      fs = Ns * 12 * (recRead(7) / recRead(17))

      Haf = 1 - ((Ro) / (2 * Rom * 1728))

      If recRead(11) = 1 Then
      Da = (recRead(16) + recRead(17)) / 2
      Else
      Da = recRead(16)
      End If

      Has1 = (Ros) / (2 * Rom * 1728)
      Has2 = 1 / (((Da / recRead(15)) ^ 2) - 1)
      Has = 1 - (Has1 * Has2)

      I = 3.14 * (Da ^ 4 - recRead(15) ^ 4) / 64

      M = Rom * 3.14 * (Da ^ 2 - recRead(15) ^ 2) / 4

      Fa1 = ((1.875 ^ 2) / 6.28) * (((E * I * 386.088) / M) ^ 0.5)
      Fa = Fa1 / (recRead(12) ^ 2)

      Hf1 = 0.99 * (1 + (1 - (recRead(17) / recRead(16))) + ((1 - (recRead(17) / recRead(16))) ^ 2))
      Hf2 = 1 + 1.1 * ((Da / recRead(12)) ^ (3 * (1 - 0.8 * (recRead(15) / Da))))
      Hf = Hf1 / Hf2

      Fn = Hf * Fa * Haf * Has

      Hc = 1 - (0.61 * (recRead(16) / recRead(12)))

      Fnc = Hc * Fn

      Nsc1 = (3.14 ^ 2) * Delta
      Nsc2 = Rom / ((Ro * 5.787 * (10 ^ -4)))
      Nsc3 = 1 - (recRead(15) / recRead(17)) ^ 2
      Nsc = Nsc1 * Nsc2 * Nsc3

      Vir = (recRead(17) / 12 * Fnc) / (2 * Ns)

      Gsp1 = 16 * (recRead(12) ^ 2)
      Gsp2 = (3 * 3.14 * (recRead(16) ^ 2)) * (1 - (recRead(15) / recRead(16)) ^ 4)
      Gsp3 = 1 + 2 * (recRead(17) / recRead(16))
      Gsp = (Gsp1 * Gsp3) / Gsp2

      Pd = (0.5 * Ro * 5.787 * 10 ^ -4 * Vir ^ 2 * 0.1 * 12 ^ 2) / 386.088

      Sd = Gsp * Pd * 1000

      ABRatio = recRead(16) / recRead(17)

      If ABRatio > 1.2992 Then
      Kt = 2.2
      Else
      Kt = 1.1 + 0.033 * ABRatio
      End If

      Somax = Kt * Sd

      FtFeSf = Ft * Sf

      Sr = recRead(6)

      St1 = 1 + (recRead(15) / recRead(16)) ^ 2
      St2 = 1 - (recRead(15) / recRead(16)) ^ 2
      St = Sr * (St1 / St2)

      Sa = Sr / St2

      Pd1 = (0.5 * Ro * 5.787 * 10 ^ -4 * 1.4 * (recRead(7) ^ 2) * 12 ^ 2) / 386.088

      Sd1 = Gsp * Pd1

      Smax = Sd1 + Sa

      LHS = Sqr(((Smax - Sr) ^ 2 + (Smax - St) ^ 2 + (St - Sr) ^ 2) / 2)

      RHS = 1.5 * S

      r = fs / Fnc

      Fm = 1 / (1 - (r ^ 2))

      r1 = 2 * r

      Fm1 = 1 / (1 - (r1 ^ 2))

      Pd2 = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 0.1) / 386.088

      Pt = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 1) / 386.088

      Sd2 = Fm1 * Pd2 * Gsp

      St3 = Gsp * Fm * Pt

      Smax1 = 2.2 * ((Sd2 ^ 2 + St3 ^ 2) ^ 0.5)

      FtFeSf1 = Ft * Sf

      Pc = (0.66 * S) * (2.167 / ((2 * recRead(17)) / (recRead(17) - recRead(15)))) - 0.0833

      Pt1 = (S / 0.13) * (recRead(18) / recRead(15)) ^ 2

      If recMaterial.State = 1 Then recMaterial.Close
      strMaterial = "select MatDesc from Materials where [ID]='" & recRead(4) & "'"
      recMaterial.Open strMaterial, conThermowell, adOpenDynamic, adLockPessimistic

      If recInsert.State = 1 Then recInsert.Close
      strInsert = "insert into OutputRes values ('" & recRead(1) & "','" & recRead(2) & "','" & recRead(3) & "','" & recMaterial(0) & "'," & _
      "" & recRead(5) & "," & recRead(6) & "," & recRead(7) & "," & recRead(8) & "," & recRead(9) & "," & recRead(10) & "," & recRead(11) & "," & _
      "" & recRead(12) & "," & recRead(13) & "," & recRead(14) & "," & recRead(15) & "," & recRead(16) & "," & recRead(17) & "," & recRead(18) & "," & _
      "" & recRead(19) & "," & recRead(20) & ",'" & recRead(21) & "','" & recRead(22) & "','" & recRead(23) & "'," & Sf & "," & Re & "," & E & "," & S & "," & Rom & "," & _
      "" & ModElasticity & "," & MaxWorkStress & "," & StrouhalNum & "," & Ns & "," & fs & "," & Haf & "," & Da & "," & Has & "," & _
      "" & M & "," & Fa & "," & Hf & "," & Fn & "," & Hc & "," & Fnc & "," & Nsc & "," & Vir & "," & Gsp & "," & Pd & "," & Sd & "," & _
      "" & ABRatio & "," & Kt & "," & Somax & "," & FtFeSf & "," & Sr & "," & St & "," & Sa & "," & Pd1 & "," & Sd1 & "," & Smax & "," & _
      "" & LHS & "," & RHS & "," & r & "," & Fm & "," & r1 & "," & Fm1 & "," & Pd2 & "," & Pt & "," & Sd2 & "," & St3 & "," & Smax1 & "," & _
      "" & FtFeSf1 & "," & MatDensity & "," & Ro & "," & Ros & "," & Delta & "," & Ft & "," & Pc & "," & Pt1 & ")"
      recInsert.Open strInsert, conThermowell, adOpenDynamic, adLockPessimistic

      recRead.MoveNext
      Loop
      End Sub








      share







      New contributor




      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      Private Sub btnCalculate_Click()
      {
      Calculations
      With crlReport
      .ReportFileName = App.Path & "Output.rpt"
      .Action = 1
      End With
      End Sub



      Private Sub Calculations()
      'On Error Resume Next
      Dim strRead, strFatigue, strInsert, strDelete, strMaterial As String
      Dim Sf, Re, ModElasticity, MaxWorkStress, StrouhalNum, MatDensity, Ns, fs, Ro, Haf, Da, Ros, Has1, Has2, Has, I, M, Fa1, Fa, Hf1, Hf2, Hf, Fn, Hc, Fnc As Double
      Dim Delta, Nsc1, Nsc2, Nsc3, Nsc, Vir, Gsp1, Gsp2, Gsp3, Gsp, Pd, Sd, ABRatio, Kt, Somax, Ft, FtFeSf, Sr, St1, St2, St, Sa, Pd1, Sd1, Smax, LHS, RHS As Double
      Dim r, Fm, r1, Fm1, Pd2, Pt, Sd2, St3, Smax1, FtFeSf1, Pc, Pt1 As Double

      Set recRead = New ADODB.Recordset
      Set recFatigue = New ADODB.Recordset
      Set recInsert = New ADODB.Recordset
      Set recDelete = New ADODB.Recordset
      Set recMaterial = New ADODB.Recordset

      If recRead.State = 1 Then recRead.Close
      strRead = "select * from Simplex order by SNO"
      recRead.Open strRead, conThermowell, adOpenDynamic, adLockPessimistic

      If recDelete.State = 1 Then recDelete.Close
      strDelete = "Truncate table OutputRes"
      recDelete.Open strDelete, conThermowell, adOpenDynamic, adLockPessimistic

      Do While Not (recRead.EOF)
      If recFatigue.State = 1 Then recFatigue.Close
      strFatigue = "select value from Fatigue where FatigueID='" & Trim(recRead(21)) & "'"
      recFatigue.Open strFatigue, conThermowell, adOpenDynamic, adLockPessimistic

      MatDensity = 0.22
      Ros = 169
      Ro = 0.499
      Delta = 0.0005
      Ft = 0.9386
      Sf = 0
      Re = 0
      E = 0
      S = 0
      Rom = 0
      ModElasticity = 0
      MaxWorkStress = 0
      StrouhalNum = 0
      Ns = 0
      fs = 0
      Haf = 0
      Da = 0
      Has = 0
      M = 0
      Fa = 0
      Hf = 0
      Fn = 0
      Hc = 0
      Fnc = 0
      Nsc = 0
      Vir = 0
      Gsp = 0
      Pd = 0
      Sd = 0
      ABRatio = 0
      Kt = 0
      Somax = 0
      FtFeSf = 0
      Sr = 0
      St = 0
      Sa = 0
      Pd1 = 0
      Sd1 = 0
      Smax = 0
      LHS = 0
      RHS = 0
      r = 0
      Fm = 0
      r1 = 0
      Fm1 = 0
      Pd2 = 0
      Pt = 0
      Sd2 = 0
      St3 = 0
      Smax1 = 0
      FtFeSf1 = 0
      Pc = 0
      Pt1 = 0

      Call Modulous(recRead(4), recRead(5))
      Call Stress(recRead(4), recRead(5))
      Call SpecificWeight(recRead(4), recRead(5))

      Sf = recFatigue(0)
      Re = (recReadZ(7) * recRead(17) * recRead(9)) / (recRead(10) * 6.7197 * 0.0001 * 12)

      ModElasticity = 0.22 * (1 - (22 / Re))
      MaxWorkStress = 0.213 - 0.0248 * Math.Log((Re / 1300) ^ 2) / Math.Log(10) + 0.0095 * Math.Log((Re / 1300) ^ 3) / Math.Log(10)

      If Re > 21.999 And Re < 1300 Then
      StrouhalNum = ModElasticity
      ElseIf Re > 1299.9999 And Re < 500000 Then
      StrouhalNum = MaxWorkStress
      Else
      StrouhalNum = MatDensity
      End If

      Ns = StrouhalNum

      fs = Ns * 12 * (recRead(7) / recRead(17))

      Haf = 1 - ((Ro) / (2 * Rom * 1728))

      If recRead(11) = 1 Then
      Da = (recRead(16) + recRead(17)) / 2
      Else
      Da = recRead(16)
      End If

      Has1 = (Ros) / (2 * Rom * 1728)
      Has2 = 1 / (((Da / recRead(15)) ^ 2) - 1)
      Has = 1 - (Has1 * Has2)

      I = 3.14 * (Da ^ 4 - recRead(15) ^ 4) / 64

      M = Rom * 3.14 * (Da ^ 2 - recRead(15) ^ 2) / 4

      Fa1 = ((1.875 ^ 2) / 6.28) * (((E * I * 386.088) / M) ^ 0.5)
      Fa = Fa1 / (recRead(12) ^ 2)

      Hf1 = 0.99 * (1 + (1 - (recRead(17) / recRead(16))) + ((1 - (recRead(17) / recRead(16))) ^ 2))
      Hf2 = 1 + 1.1 * ((Da / recRead(12)) ^ (3 * (1 - 0.8 * (recRead(15) / Da))))
      Hf = Hf1 / Hf2

      Fn = Hf * Fa * Haf * Has

      Hc = 1 - (0.61 * (recRead(16) / recRead(12)))

      Fnc = Hc * Fn

      Nsc1 = (3.14 ^ 2) * Delta
      Nsc2 = Rom / ((Ro * 5.787 * (10 ^ -4)))
      Nsc3 = 1 - (recRead(15) / recRead(17)) ^ 2
      Nsc = Nsc1 * Nsc2 * Nsc3

      Vir = (recRead(17) / 12 * Fnc) / (2 * Ns)

      Gsp1 = 16 * (recRead(12) ^ 2)
      Gsp2 = (3 * 3.14 * (recRead(16) ^ 2)) * (1 - (recRead(15) / recRead(16)) ^ 4)
      Gsp3 = 1 + 2 * (recRead(17) / recRead(16))
      Gsp = (Gsp1 * Gsp3) / Gsp2

      Pd = (0.5 * Ro * 5.787 * 10 ^ -4 * Vir ^ 2 * 0.1 * 12 ^ 2) / 386.088

      Sd = Gsp * Pd * 1000

      ABRatio = recRead(16) / recRead(17)

      If ABRatio > 1.2992 Then
      Kt = 2.2
      Else
      Kt = 1.1 + 0.033 * ABRatio
      End If

      Somax = Kt * Sd

      FtFeSf = Ft * Sf

      Sr = recRead(6)

      St1 = 1 + (recRead(15) / recRead(16)) ^ 2
      St2 = 1 - (recRead(15) / recRead(16)) ^ 2
      St = Sr * (St1 / St2)

      Sa = Sr / St2

      Pd1 = (0.5 * Ro * 5.787 * 10 ^ -4 * 1.4 * (recRead(7) ^ 2) * 12 ^ 2) / 386.088

      Sd1 = Gsp * Pd1

      Smax = Sd1 + Sa

      LHS = Sqr(((Smax - Sr) ^ 2 + (Smax - St) ^ 2 + (St - Sr) ^ 2) / 2)

      RHS = 1.5 * S

      r = fs / Fnc

      Fm = 1 / (1 - (r ^ 2))

      r1 = 2 * r

      Fm1 = 1 / (1 - (r1 ^ 2))

      Pd2 = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 0.1) / 386.088

      Pt = (0.5 * Ro * 5.787 * 10 ^ -4 * recRead(7) ^ 2 * 12 ^ 2 * 1) / 386.088

      Sd2 = Fm1 * Pd2 * Gsp

      St3 = Gsp * Fm * Pt

      Smax1 = 2.2 * ((Sd2 ^ 2 + St3 ^ 2) ^ 0.5)

      FtFeSf1 = Ft * Sf

      Pc = (0.66 * S) * (2.167 / ((2 * recRead(17)) / (recRead(17) - recRead(15)))) - 0.0833

      Pt1 = (S / 0.13) * (recRead(18) / recRead(15)) ^ 2

      If recMaterial.State = 1 Then recMaterial.Close
      strMaterial = "select MatDesc from Materials where [ID]='" & recRead(4) & "'"
      recMaterial.Open strMaterial, conThermowell, adOpenDynamic, adLockPessimistic

      If recInsert.State = 1 Then recInsert.Close
      strInsert = "insert into OutputRes values ('" & recRead(1) & "','" & recRead(2) & "','" & recRead(3) & "','" & recMaterial(0) & "'," & _
      "" & recRead(5) & "," & recRead(6) & "," & recRead(7) & "," & recRead(8) & "," & recRead(9) & "," & recRead(10) & "," & recRead(11) & "," & _
      "" & recRead(12) & "," & recRead(13) & "," & recRead(14) & "," & recRead(15) & "," & recRead(16) & "," & recRead(17) & "," & recRead(18) & "," & _
      "" & recRead(19) & "," & recRead(20) & ",'" & recRead(21) & "','" & recRead(22) & "','" & recRead(23) & "'," & Sf & "," & Re & "," & E & "," & S & "," & Rom & "," & _
      "" & ModElasticity & "," & MaxWorkStress & "," & StrouhalNum & "," & Ns & "," & fs & "," & Haf & "," & Da & "," & Has & "," & _
      "" & M & "," & Fa & "," & Hf & "," & Fn & "," & Hc & "," & Fnc & "," & Nsc & "," & Vir & "," & Gsp & "," & Pd & "," & Sd & "," & _
      "" & ABRatio & "," & Kt & "," & Somax & "," & FtFeSf & "," & Sr & "," & St & "," & Sa & "," & Pd1 & "," & Sd1 & "," & Smax & "," & _
      "" & LHS & "," & RHS & "," & r & "," & Fm & "," & r1 & "," & Fm1 & "," & Pd2 & "," & Pt & "," & Sd2 & "," & St3 & "," & Smax1 & "," & _
      "" & FtFeSf1 & "," & MatDensity & "," & Ro & "," & Ros & "," & Delta & "," & Ft & "," & Pc & "," & Pt1 & ")"
      recInsert.Open strInsert, conThermowell, adOpenDynamic, adLockPessimistic

      recRead.MoveNext
      Loop
      End Sub






      c# winforms





      share







      New contributor




      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 6 mins ago









      user194219user194219

      1




      1




      New contributor




      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      user194219 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          user194219 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214590%2fvb6-to-c-perform-functionality-in-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          user194219 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          user194219 is a new contributor. Be nice, and check out our Code of Conduct.













          user194219 is a new contributor. Be nice, and check out our Code of Conduct.












          user194219 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214590%2fvb6-to-c-perform-functionality-in-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀