I am creating a program for tower. I have some cases 1 to 8. when I am calculating the FOS at that type I have to call those cases every time then the program is lenghty. I am writing my code. I want to convert it to cases through function and the calculating time How I call that function value like.... RMin, RMed, RMax, SEction & KgM. How will Code comes. Can somebody help me. Give me the sub to function procedure and How will I call them by Calculation time.
and main sub (Calculation time)Code:Private Sub SEcVar() Select Case Number ' Evaluate Number. Case 1 ' Number is 1 and Section is 40x40x3 RMin = 0.77 RMed = 1.21 RMax = 1.54 SEction = "40x40x3" SqCm = 2.34 KgM = 1.8 Case 2 ' Number is 2 and Section is 40x40x4 RMin = 0.77 RMed = 1.21 RMax = 1.53 SEction = "40x40x4" SqCm = 3.07 KgM = 2.4 Case 3 ' Number is 3 and Section is 40x40x5 RMin = 0.77 RMed = 1.2 RMax = 1.51 SEction = "40x40x5" SqCm = 3.78 KgM = 3# Case 4 ' Number is 4 and Section is 40x40x6 RMin = 0.77 RMed = 1.19 RMax = 1.5 SEction = "40x40x6" SqCm = 4.47 KgM = 3.5 Case 5 ' Number is 1 and Section is 45x45x3 RMin = 0.87 RMed = 1.38 RMax = 1.74 SEction = "45x45x3" SqCm = 2.64 Case 6 ' Number is 2 and Section is 45x45x4 RMin = 0.87 RMed = 1.37 RMax = 1.73 SEction = "45x45x4" SqCm = 2.64 Case 7 ' Number is 3 and Section is 45x45x5 RMin = 0.87 RMed = 1.36 RMax = 1.72 SEction = "45x45x5" SqCm = 2.64 Case 8 ' Number is 4 and Section is 45x45x6 RMin = 0.87 RMed = 1.35 RMax = 1.7 SEction = "45x45x6" SqCm = 2.64 Case Else ' Other values. End Select End Sub
[ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]Code:Private Sub towerpoints1() Dim DesignLen As Variant DesignLen = ((Panelh1 / 4) / 10#) 'Calculate L Dim Curve As Integer Dim C As Variant Curve = TextBox3.Value C = TextBox2.Value Dim KLR As Variant Dim LR As Variant Dim ISec As Integer Number = 1 Dim UCS As Variant Dim Fa As Variant 'SEcVar Do While fos < 1.1 'And fos < 1.3 SEcVar LR = DesignLen / RMin If Curve = 1 Then KLR = LR End If If Curve = 2 Then KLR = (30 + (0.75 * LR)) End If If Curve = 3 Then KLR = (60 + (0.5 * LR)) End If If Curve = 4 Then KLR = LR End If If Curve = 5 Then KLR = (28.6 + (0.762 * LR)) End If If Curve = 6 Then KLR = (46.2 + (0.615 * LR)) End If Fa = (2600 - (0.083969944 * (KLR ^ 2))) UCS = Fa * SqCm fos = UCS / C Number = Number + 1 Loop Debug.Print "Section Selected is = " & SEction Debug.Print "Design Length = " & DesignLen Debug.Print "KgM = " & KgM End Sub