TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Amit Bhawsar
NA
10
770
> My VB6 code is working fine, I want to change this code in
Mar 2 2019 1:02 AM
Private Sub bttCalculate_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
Reply
Answers (
4
)
bank account inheritance
disable Windows 10 in the upgrade