Taking Values from another form to Table layout panel ("How?")

Beginner

Well-known member
Joined
Mar 12, 2008
Messages
114
Programming Experience
Beginner
Ok guys heres what i want to do.

When i hit the Calculate Button on form1.

I want To do this ....
[GIF ANIMATED IMAGE]

12fl8.gif


Diametral Pitch is located under Form1

While where i want the value to show is Common_Features

So what approach do i use do i create a text box ? Or a label ? I want no user input just the number in a nice way
 
How man i fix this ?

VB.NET:
Public Class Form1
    Dim Pressure_Angle_Result As Double
    Dim Pressure_angle_Radian As Double
Dim Diametral_Pitch As Double


VB.NET:
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Pressure_angle_Radian = CDbl(Pa.Text)
        Diametral_Pitch = CDbl(dp.Text)
    End Sub

VB.NET:
 Private Sub pa_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
    End Sub

Am i on the correct track ? because its working fine and im getting the numbers to show. The number of errors have reduced to 19.

2001510968956349867_rs.jpg
 
Double to String Error

VB.NET:
Common_Features.Addendum.Text = (1 / (Diametral_Pitch))

Correction:


VB.NET:
Common_Features.Addendum.Text = (1 / (Diametral_Pitch)).ToString


How do i fix the String to Double error for this one ?

VB.NET:
 Common_Features.Addendum1.Text = (Common_Features.Addendum.Text) * 25.4
 
How do i fix the String to Double error for this one ?

VB.NET:
 Common_Features.Addendum1.Text = (Common_Features.Addendum.Text) * 25.4

VB.NET:
Common_Features.Addendum1.Text = (CDbl(Common_Features.Addendum.Text) * 25.4).ToString
 
VB.NET:
   Private Sub Form1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        Dim Diametral_Pitch As Double
        Dim Velocity_Ratio As Double
        Dim gear As Double
        Dim Pressure_Angle_Result As Double
        Dim Pressure_angle_Radian As Double
        Dim addendum, addendum1, dedendum, dedendum1 As Double
        Dim Pinion1, Pitch_Radiusp1, Pitch_Radiusp2 As Double
        Dim Base_Circlep1, Base_Circlep2 As Double
        Dim Outer_Circlep1, Outer_Circlep2 As Double
        Dim Working_Depthp1, Working_Depthp2 As Double
        Dim Clearance, Clearance1 As Double
        Dim root_radiusp1, root_radiusp2 As Double
        Dim Whole_depthp1, Whole_depthp2 As Double

        Pressure_angle_Radian = CDbl(Pa.Text)
        Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
        Diametral_Pitch = CDbl(dp.Text)


        addendum = 1 / Diametral_Pitch
        Common_Features.Addendum.Text = addendum.ToString

        addendum1 = (addendum * 25.4)
        Common_Features.Addendum1.Text = addendum1.ToString




        If Diametral_Pitch < 20 Then
            dedendum = (1.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            dedendum = ((1.2 / Diametral_Pitch) + 0.002)
        End If
        Common_Features.Dedendum.Text = dedendum.ToString
        dedendum1 = dedendum * 25.4
        Common_Features.Dedendum1.Text = dedendum1.ToString



        If Diametral_Pitch < 20 Then
            Clearance = (0.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            Clearance = ((0.2 / Diametral_Pitch) + 0.002)
        End If

        Common_Features.clearance.Text = Clearance.ToString
        Clearance1 = Clearance * 25.4
        Common_Features.clearance1.Text = Clearance1.ToString

        Velocity_Ratio = CDbl(vr.Text)
        gear = CDbl(gearteeth1.Text)

        Pinion1 = Math.Floor(Velocity_Ratio * gear)
        Pinion_Features.pinion1.Text = Pinion1.ToString

        Pitch_Radiusp1 = (Pinion1 / Diametral_Pitch) / 2
        Pinion_Features.Pitch_Radiusp1.Text = Pitch_Radiusp1.ToString

        Pitch_Radiusp2 = Pitch_Radiusp1 * 25.4
        Pinion_Features.Pitch_Radiusp2.Text = Pitch_Radiusp2.ToString

        Base_Circlep1 = Pitch_Radiusp1 * Math.Cos(Pressure_Angle_Result)
        Pinion_Features.Base_Circlep1.Text = Base_Circlep1.ToString

        Base_Circlep2 = Base_Circlep1 * 25.4
        Pinion_Features.Base_Circlep2.Text = Base_Circlep2.ToString

        Outer_Circlep1 = dedendum + Pitch_Radiusp1
        Pinion_Features.Outer_Circlep1.Text = Outer_Circlep1.ToString

        Outer_Circlep2 = Outer_Circlep1 * 25.4
        Pinion_Features.Outer_Circlep2.Text = Outer_Circlep2.ToString


        root_radiusp1 = (Pitch_Radiusp1 - dedendum)
        Pinion_Features.Root_Radiusp1.Text = root_radiusp1.ToString
        root_radiusp2 = root_radiusp1 * 25.4
        Pinion_Features.Root_Radiusp2.Text = root_radiusp2.ToString

        Whole_depthp1 = addendum + dedendum
        Pinion_Features.Whole_Depthp1.Text = Whole_depthp1.ToString
        Whole_depthp2 = Whole_depthp1 * 25.4
        Pinion_Features.Whole_Depthp2.Text = Whole_depthp2.ToString


        Working_Depthp1 = addendum * 2
        Pinion_Features.Working_Depthp1.Text = Working_Depthp1.ToString
        Working_Depthp2 = Working_Depthp1 * 25.4
        Pinion_Features.Working_Depthp2.Text = Working_Depthp2.ToString




    End Sub
End Class

I think im fine now.

is this a good place to put the code in ?

Private Sub Form1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
 
The form's VisibleChanged event is only fired when the Form's Visible (True/False) property is changed

Typically this event is never used, but it's there in case you have a situation where you need to use it (your program doesn't have that situation)
 
The form's VisibleChanged event is only fired when the Form's Visible (True/False) property is changed

Typically this event is never used, but it's there in case you have a situation where you need to use it (your program doesn't have that situation)


Thanx So where shall i put my code ?
 
Im stuck again ... code is fine but calculations arent showing correct.

2001562218659344826_rs.jpg




VB.NET:
  Private Sub Form1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        Dim Diametral_Pitch As Double
        Dim Velocity_Ratio As Double
        Dim gear As Double
        Dim Pressure_Angle As Double
        Dim Pressure_Angle_Result As Double
        Dim Pressure_angle_Radian As Double
        Dim addendum, addendum1, dedendum, dedendum1 As Double
        Dim Clearance, Clearance1 As Double
        'Pinion Parameteres
        Dim Pinion1, Pitch_Radiusp1, Pitch_Radiusp2 As Double
        Dim Base_Circlep1, Base_Circlep2 As Double
        Dim Outer_Circlep1, Outer_Circlep2 As Double
        Dim Working_Depthp1, Working_Depthp2 As Double
        Dim root_radiusp1, root_radiusp2 As Double
        Dim Whole_depthp1, Whole_depthp2 As Double
        'Gear Dimmed parameters
        Dim Pitch_radiusg1, Pitch_radiusg2 As Double
        Dim Base_Circleg1, Base_Circleg2 As Double
        Dim Outer_Circleg1, Outer_Circleg2 As Double
        Dim Working_Depthg1, Working_Depthg2 As Double
        Dim root_Circleg1, root_Circleg2 As Double
        Dim Whole_depthg1, Whole_depthg2 As Double
        Dim toolg1, toolg2 As Double
        Dim rotation_angleg1, rotation_angleg2 As Double

        gear = CDbl(gearteeth1.Text)
        Pressure_Angle = CDbl(dp.Text)
        Pressure_angle_Radian = CDbl(Pa.Text)
        Pressure_Angle_Result = ((Pressure_angle_Radian * Math.PI) / 180)



        Pitch_radiusg1 = (gear / Pressure_Angle) / 2
        Gear_Features.Pitch_radiusg1.Text = Pitch_radiusg1.ToString
        Pitch_radiusg2 = Pitch_radiusg1 * 25.4
        Gear_Features.Pitch_radiusg2.Text = Pitch_radiusg2.ToString

        Base_Circleg1 = Pitch_radiusg1 * Math.Cos(Pressure_Angle_Result)
        Gear_Features.Base_Circleg1.Text = Base_Circleg1.ToString

        Base_Circleg2 = Base_Circleg1 * 25.4
        Gear_Features.Base_Circleg2.Text = Base_Circleg2.ToString


        Outer_Circleg1 = Pitch_radiusg1 + addendum
        Gear_Features.Outer_Circleg1.Text = Outer_Circleg1.ToString

        Outer_Circleg2 = Outer_Circleg1 * 25.4
        Gear_Features.Outer_Circleg2.Text = Outer_Circleg2.ToString

        root_Circleg1 = Pitch_radiusg1 - dedendum
        Gear_Features.Root_Circleg1.Text = root_Circleg1.ToString

        root_Circleg2 = root_Circleg1 * 25.4
        Gear_Features.Root_Circleg2.Text = root_Circleg2.ToString

        Whole_depthg1 = addendum + dedendum
        Gear_Features.Whole_depthg1.Text = Whole_depthg1.ToString

        Whole_depthg2 = Whole_depthg1 * 25.4
        Gear_Features.Whole_depthg2.Text = Whole_depthg2.ToString

        Working_Depthg1 = 2 * addendum
        Gear_Features.Working_Depthg1.Text = Working_Depthg1.ToString

        Working_Depthg2 = Working_Depthg1 * 25.4
        Gear_Features.Working_depthg2.Text = Working_Depthg2.ToString

        toolg1 = Math.PI / (2 * Diametral_Pitch)
        Gear_Features.Toolg1.Text = toolg1.ToString

        toolg2 = toolg1 * 25.4
        Gear_Features.Toolg2.Text = toolg2.ToString

        Rotation_angleg1 = (toolg1 * (Pitch_radiusg1 / Base_Circleg1)) / Base_Circleg1
        Gear_Features.Rotation_angleg1.Text = rotation_angleg1.ToString


        rotation_angleg2 = (toolg1 * (Pitch_radiusg1 / Base_Circleg1)) / Base_Circleg1
        Gear_Features.Rotation_angleg2.Text = rotation_angleg2.ToString




        Pressure_angle_Radian = CDbl(Pa.Text)
        Pressure_Angle_Result = ((Pressure_angle_Radian * Math.PI) / 180)
        Diametral_Pitch = CDbl(dp.Text)


        addendum = 1 / Diametral_Pitch
        Common_Features.Addendum.Text = addendum.ToString

        addendum1 = (addendum * 25.4)
        Common_Features.Addendum1.Text = addendum1.ToString




        If Diametral_Pitch < 20 Then
            dedendum = (1.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            dedendum = ((1.2 / Diametral_Pitch) + 0.002)
        End If
        Common_Features.Dedendum.Text = dedendum.ToString
        dedendum1 = dedendum * 25.4
        Common_Features.Dedendum1.Text = dedendum1.ToString



        If Diametral_Pitch < 20 Then
            Clearance = (0.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            Clearance = ((0.2 / Diametral_Pitch) + 0.002)
        End If

        Common_Features.clearance.Text = Clearance.ToString
        Clearance1 = Clearance * 25.4
        Common_Features.clearance1.Text = Clearance1.ToString

        Velocity_Ratio = CDbl(vr.Text)


        Pinion1 = Math.Floor(Velocity_Ratio * gear)
        Pinion_Features.pinion1.Text = Pinion1.ToString

        Pitch_Radiusp1 = (Pinion1 / Diametral_Pitch) / 2
        Pinion_Features.Pitch_Radiusp1.Text = Pitch_Radiusp1.ToString

        Pitch_Radiusp2 = Pitch_Radiusp1 * 25.4
        Pinion_Features.Pitch_Radiusp2.Text = Pitch_Radiusp2.ToString

        Base_Circlep1 = Pitch_Radiusp1 * Math.Cos(Pressure_Angle_Result)
        Pinion_Features.Base_Circlep1.Text = Base_Circlep1.ToString

        Base_Circlep2 = Base_Circlep1 * 25.4
        Pinion_Features.Base_Circlep2.Text = Base_Circlep2.ToString

        Outer_Circlep1 = dedendum + Pitch_Radiusp1
        Pinion_Features.Outer_Circlep1.Text = Outer_Circlep1.ToString

        Outer_Circlep2 = Outer_Circlep1 * 25.4
        Pinion_Features.Outer_Circlep2.Text = Outer_Circlep2.ToString


        root_radiusp1 = (Pitch_Radiusp1 - dedendum)
        Pinion_Features.Root_Radiusp1.Text = root_radiusp1.ToString
        root_radiusp2 = root_radiusp1 * 25.4
        Pinion_Features.Root_Radiusp2.Text = root_radiusp2.ToString

        Whole_depthp1 = addendum + dedendum
        Pinion_Features.Whole_Depthp1.Text = Whole_depthp1.ToString
        Whole_depthp2 = Whole_depthp1 * 25.4
        Pinion_Features.Whole_Depthp2.Text = Whole_depthp2.ToString


        Working_Depthp1 = addendum * 2
        Pinion_Features.Working_Depthp1.Text = Working_Depthp1.ToString
        Working_Depthp2 = Working_Depthp1 * 25.4
        Pinion_Features.Working_Depthp2.Text = Working_Depthp2.ToString




    End Sub
End Class
 
Problem Solved.

VB.NET:
  Private Sub Form1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        Dim Diametral_Pitch As Double
        Dim Velocity_Ratio As Double
        Dim gear As Double
        Dim Pressure_Angle As Double
        Dim Pressure_Angle_Result As Double
        Dim Pressure_angle_Radian As Double
        Dim addendum, addendum1, dedendum, dedendum1 As Double
        Dim Clearance, Clearance1 As Double

        gear = CDbl(gearteeth1.Text)
        Pressure_Angle = CDbl(dp.Text)
        Pressure_angle_Radian = CDbl(Pa.Text)
        Pressure_Angle_Result = ((Pressure_angle_Radian * Math.PI) / 180)
        Diametral_Pitch = CDbl(dp.Text)

        addendum = 1 / Diametral_Pitch
        Common_Features.Addendum.Text = addendum.ToString

        addendum1 = (addendum * 25.4)
        Common_Features.Addendum1.Text = addendum1.ToString

        If Diametral_Pitch < 20 Then
            dedendum = (1.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            dedendum = ((1.2 / Diametral_Pitch) + 0.002)
        End If
        Common_Features.Dedendum.Text = dedendum.ToString
        dedendum1 = dedendum * 25.4
        Common_Features.Dedendum1.Text = dedendum1.ToString

        If Diametral_Pitch < 20 Then
            Clearance = (0.25 / Diametral_Pitch)
        ElseIf Diametral_Pitch > 20 Then
            Clearance = ((0.2 / Diametral_Pitch) + 0.002)
        End If

        Common_Features.clearance.Text = Clearance.ToString
        Clearance1 = Clearance * 25.4
        Common_Features.clearance1.Text = Clearance1.ToString

        Velocity_Ratio = CDbl(vr.Text)

        'Pinion Parameteres
        Dim Pinion1, Pitch_Radiusp1, Pitch_Radiusp2 As Double
        Dim Base_Circlep1, Base_Circlep2 As Double
        Dim Outer_Circlep1, Outer_Circlep2 As Double
        Dim Working_Depthp1, Working_Depthp2 As Double
        Dim root_circlep1, root_circlep2 As Double
        Dim Whole_depthp1, Whole_depthp2 As Double
        Dim toolp1, toolp2 As Double
        Dim Rotation_Anglep1, Rotation_Anglep2 As Double

        Pinion1 = Math.Floor(Velocity_Ratio * gear)
        Pinion_Features.pinion1.Text = Pinion1.ToString

        Pitch_Radiusp1 = (Pinion1 / Diametral_Pitch) / 2
        Pinion_Features.Pitch_Radiusp1.Text = Pitch_Radiusp1.ToString

        Pitch_Radiusp2 = Pitch_Radiusp1 * 25.4
        Pinion_Features.Pitch_Radiusp2.Text = Pitch_Radiusp2.ToString

        Base_Circlep1 = Pitch_Radiusp1 * Math.Cos(Pressure_Angle_Result)
        Pinion_Features.Base_Circlep1.Text = Base_Circlep1.ToString

        Base_Circlep2 = Base_Circlep1 * 25.4
        Pinion_Features.Base_Circlep2.Text = Base_Circlep2.ToString

        Outer_Circlep1 = dedendum + Pitch_Radiusp1
        Pinion_Features.Outer_Circlep1.Text = Outer_Circlep1.ToString

        Outer_Circlep2 = Outer_Circlep1 * 25.4
        Pinion_Features.Outer_Circlep2.Text = Outer_Circlep2.ToString


        root_circlep1 = (Pitch_Radiusp1 - dedendum)
        Pinion_Features.Root_Circlep1.Text = root_circlep1.ToString

        root_circlep2 = root_circlep1 * 25.4
        Pinion_Features.Root_Circlep2.Text = root_circlep2.ToString

        Whole_depthp1 = addendum + dedendum
        Pinion_Features.Whole_Depthp1.Text = Whole_depthp1.ToString
        Whole_depthp2 = Whole_depthp1 * 25.4
        Pinion_Features.Whole_Depthp2.Text = Whole_depthp2.ToString


        Working_Depthp1 = addendum * 2
        Pinion_Features.Working_Depthp1.Text = Working_Depthp1.ToString
        Working_Depthp2 = Working_Depthp1 * 25.4
        Pinion_Features.Working_Depthp2.Text = Working_Depthp2.ToString


        toolp1 = Math.PI / (2 * Diametral_Pitch)
        Pinion_Features.toolp1.Text = toolp1.ToString

        toolp2 = toolp1 * 25.4
        Pinion_Features.toolp2.Text = toolp2.ToString

        Rotation_Anglep1 = toolp1 * (Pitch_Radiusp1 / Base_Circlep1) / Base_Circlep1
        Pinion_Features.Rotation_Anglep1.Text = Rotation_Anglep1.ToString

        Rotation_Anglep2 = toolp2 * (Pitch_Radiusp2 / Base_Circlep2) / Base_Circlep2
        Pinion_Features.Rotation_Anglep2.Text = Rotation_Anglep1.ToString

        'Gear Dimmed parameters
        Dim Pitch_radiusg1, Pitch_radiusg2 As Double
        Dim Base_Circleg1, Base_Circleg2 As Double
        Dim Outer_Circleg1, Outer_Circleg2 As Double
        Dim Working_Depthg1, Working_Depthg2 As Double
        Dim root_Circleg1, root_Circleg2 As Double
        Dim Whole_depthg1, Whole_depthg2 As Double
        Dim toolg1, toolg2 As Double
        Dim rotation_angleg1, rotation_angleg2 As Double

       


        Pitch_radiusg1 = (gear / Pressure_Angle) / 2
        Gear_Features.Pitch_radiusg1.Text = Pitch_radiusg1.ToString
        Pitch_radiusg2 = Pitch_radiusg1 * 25.4
        Gear_Features.Pitch_radiusg2.Text = Pitch_radiusg2.ToString

        Base_Circleg1 = Pitch_radiusg1 * Math.Cos(Pressure_Angle_Result)
        Gear_Features.Base_Circleg1.Text = Base_Circleg1.ToString

        Base_Circleg2 = Base_Circleg1 * 25.4
        Gear_Features.Base_Circleg2.Text = Base_Circleg2.ToString


        Outer_Circleg1 = Pitch_radiusg1 + addendum
        Gear_Features.Outer_Circleg1.Text = Outer_Circleg1.ToString

        Outer_Circleg2 = Outer_Circleg1 * 25.4
        Gear_Features.Outer_Circleg2.Text = Outer_Circleg2.ToString

        root_Circleg1 = Pitch_radiusg1 - dedendum
        Gear_Features.Root_Circleg1.Text = root_Circleg1.ToString

        root_Circleg2 = root_Circleg1 * 25.4
        Gear_Features.Root_Circleg2.Text = root_Circleg2.ToString

        Whole_depthg1 = addendum + dedendum
        Gear_Features.Whole_depthg1.Text = Whole_depthg1.ToString

        Whole_depthg2 = Whole_depthg1 * 25.4
        Gear_Features.Whole_depthg2.Text = Whole_depthg2.ToString

        Working_Depthg1 = 2 * addendum
        Gear_Features.Working_Depthg1.Text = Working_Depthg1.ToString

        Working_Depthg2 = Working_Depthg1 * 25.4
        Gear_Features.Working_depthg2.Text = Working_Depthg2.ToString

        toolg1 = Math.PI / (2 * Diametral_Pitch)
        Gear_Features.Toolg1.Text = toolg1.ToString

        toolg2 = toolg1 * 25.4
        Gear_Features.Toolg2.Text = toolg2.ToString

        rotation_angleg1 = (toolg1 * (Pitch_radiusg1 / Base_Circleg1)) / Base_Circleg1
        Gear_Features.Rotation_angleg1.Text = rotation_angleg1.ToString


        rotation_angleg2 = (toolg1 * (Pitch_radiusg1 / Base_Circleg1)) / Base_Circleg1
        Gear_Features.Rotation_angleg2.Text = rotation_angleg2.ToString

        'REMIAINING Calculations that cannot be done except after getting the 
        'above values
        'Common Feature ( Distance Center Calculation )
        Dim Distance_Center, Distance_Center1 As Double

        Distance_Center = Pitch_radiusg1 + Pitch_Radiusp1
        Common_Features.Distance_Center.Text = Distance_Center.ToString

        Distance_Center1 = Distance_Center * 25.4
        Common_Features.Distance_Center1.Text = Distance_Center1.ToString

        'Common Feature ( Contact Ratio mf )
        Dim Contact_Ratio As Double
        Dim w, x, y, z As Double
        w = Math.Sqrt((Outer_Circlep1 ^ 2) - (Base_Circlep1 ^ 2))
        x = Math.Sqrt((Outer_Circleg1 ^ 2) - (Base_Circleg1 ^ 2))
        y = (0 * Math.Sin(Pressure_Angle_Result))
        z = (3.14 * Math.Cos(Pressure_Angle_Result))
        Contact_Ratio = ((Diametral_Pitch) * (w + x - y)) / z
        Common_Features.Contact_ratio.Text = Contact_Ratio.ToString


    End Sub
End Class


2003953156700763691_rs.jpg



2003985560179078859_rs.jpg



2003901415938967009_rs.jpg


2003985560179078859_rs.jpg


2003953382222395968_rs.jpg


2003985560179078859_rs.jpg


2003903193506258163_rs.jpg
 
Back
Top