Results 1 to 25 of 25

Thread: [RESOLVED] Taking Values from another form to Table layout panel ("How?")

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

    Resolved [RESOLVED] Taking Values from another form to Table layout panel ("How?")

    Ok guys heres what i want to do.

    When i hit the Calculate Button on form1.

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



    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    I'm afraid what you're saying doesn't really make sense to me. Also, for me at least, multiple images would be preferable to an animated GIF.

    Anyway, the particulars don't really matter. You've got data that you want to move from one form to another, correct? The answer to this is always the same. You do it EXACTLY as you do for any data. Forms are just objects like any other. To get data into an object you set a property or call a method and pass a parameter. That's universal. To get data out of an object you get a property or call a function and get the return value. That's also universal. The fact that your objects are forms makes no difference whatsoever.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    No Problem I'll Re-Phrase what i said.

    My aim is to get this value.



    What is the best approch to do so ? Do i create a text box ? and place it in the (1,1) (Row, Column). ive used a paint program to insert the number 0.25 just to explain what i want

    When do i want this number to appear ? When the calculate button is hit.



    So i guess the code should go there.

    Methodology ? I dont want the number to appear just like that. Since ive built a user interface that number specifically depends on the value entered in NUD controller that ive changed its name to pd.
    This value entered here.


    now what i want to happen back in the form that ive changed its name to Common_Features , i mean this form



    A mathematical operation to take place. The concept or the rule i want to use is 1/(whatever value is entered in the pd NUD)

    So how do i implement the call function ? Call whatever value is entered in the NUD bring it up to current form then 1/value.
    Last edited by uaeXuae; Mar 19th, 2008 at 12:08 PM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    You should have already added Labels to your TableLayoutPanel at design time. You then simply set the Text property of the appropriate Label control if and when you want to display some text.

    Does the Common Feature form get displayed when you click the Calculate button on the Input form? If so then you'd handle the Click event of that button, create the Common Feature form, pass the required data in as I described earlier (set a property or pass a parameter to a method) and then show the form. Where you perform the maths is up to you. You might do it first and pass in the final value, or else you might pass in the raw data and do the maths in the new form. Do whatever is most appropriate for your app.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    No The Common Feature form Does not gets displayed when the Calculate button is clicked.

    This is how it looks like :

    1



    2



    3


  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    It's still the same story. You just have to pass the data twice. The first form passes the user input to the second form, which stores it in member variables. It can then pass that data on to the third form. As I have said, you ALWAYS pass data to and from objects the same way. How many objects and what they are makes no difference.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Thanks for explaining the concept. But ive never done something like this before. i Understand the procedure very well but dont know what to write. May you gimme some hints on passing member variables please ?

    Edit:I dont want to be taken to picture number 3. I want all calculations to be done when that button is pressed and i want to be at picture number 2. So its not jumping its a button that will do all the calculations.
    Last edited by uaeXuae; Mar 19th, 2008 at 09:18 AM.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    There are really two choices:

    1. Declare one or more properties in the target form for the data that needs to be passed in. You then create the form object and then set the appropriate properties. Setting properties you've declared yourself is exactly like setting existing properties, e.g. Text. To declare a property just type the word "property" and hit Enter. The IDE will create the skeleton which you can then flesh out as needed.

    2. Declare a constructor in the target form and add a parameter for each value you want to pass in. A constructor is just a method named "New". You then pass the data in when you create the object, rather than afterwards. To create a constructor you can select "New" from the drop-down box at the top, right of the code window, then add the parameters yourself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Thanks. Im stuck here now.


    Code that i wrote:

    Code:
    Public Class Form1
        Public Shared Diametral_Pitch As String
        Public Shared Velocity_Ratio As String
        Public Shared gear As String
        Public Shared Pressure_Angle As String
    Code:
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Diametral_Pitch = dp.Text
            Common_Features.Addendum.Text = (1 / (Diametral_Pitch))
            Common_Features.Addendum1.Text = (Common_Features.Addendum.Text) * 25.4
    
    
            If Diametral_Pitch < 20 Then
                Common_Features.Dedendum.Text = (1.25 / Diametral_Pitch).ToString
            ElseIf Diametral_Pitch > 20 Then
                Common_Features.Dedendum.Text = ((1.2 / Diametral_Pitch) + 0.002).ToString
            End If
    
            Common_Features.Dedendum1.Text = (Common_Features.Dedendum.Text * 25.4).ToString
    
            If Diametral_Pitch < 20 Then
                Common_Features.clearance.Text = (0.25 / Diametral_Pitch).ToString
            ElseIf Diametral_Pitch > 20 Then
                Common_Features.clearance.Text = ((0.2 / Diametral_Pitch) + 0.002).ToString
            End If
    
            Common_Features.clearance1.Text = (Common_Features.clearance.Text * 25.4).ToString
    
            Velocity_Ratio = vr.Text
            gear = gearteeth1.Text
            Pinion_Features.pinion1.Text = Math.Floor(Velocity_Ratio * gear)
            Pinion_Features.Pitch_Radius1.Text = (Pinion_Features.pinion1.Text / Diametral_Pitch).ToString / 2
            Pinion_Features.Pitch_Radius2.Text = (Pinion_Features.Pitch_Radius1.Text * 25.4).ToString
    
            Pressure_Angle = resultdp.Text
            Pinion_Features.Base_Circle1.Text = (Pinion_Features.Pitch_Radius1.Text) * Math.Cos(Pressure_Angle)
            Pinion_Features.Base_Circle2.Text = (Pinion_Features.Base_Circle1.Text * 25.4).ToString
            Pinion_Features.Outer_Circle1.Text = (Common_Features.Dedendum.Text) + (Pinion_Features.Pitch_Radius1.Text)
            second.Show()
            Me.Hide()
    
        End Sub
    Why arent they adding together ?It only gives the value of the Common_Features.Dedendum.text which is "0.31252" . The value of Pinion_Features.Pitch_Radius1.text Which is "2" is not being added why ?


  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Quote Originally Posted by Jenner
    Because you're adding text. It's doing exactly what you told it to: 0.3125 + 2 = 0.31252. It's like adding "Hello" + "World" = HelloWorld


    Do this:

    (CDbl(Common_Features.Dedendum.Text) + CDbl(Pinion_Features.Pitch_Radius1.Text)).ToString

    Once again, you MUST use proper variables! Programs are not like Excel, they won't convert everything for you. VB.NET when not in Strict mode will do a lot of behind the scenes conversion, but more often than not, this will get you into trouble as you've just seen.

    THANKS !!! Problem Solved :

    What does CDbl actually does ?? Take the value from the text ?
    By looking at my code do you see at anypoint where i shall add CDbl or do any modifications ?
    Thanks again :-)

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    Go to the project properties and set Option Strict to On, then you'll see all the places you should be converting or casting explicitly. Everyone should have Option Strict On all the time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    I turned it on. But may you please give me an example on how it will affect the code or if something was missing how will it deal with it ? Im still not sure what it does. A short example would be best ;-)


    Edit: I tried running the program and i got 31 errors ! I didnt undertand a word from the errors may you please help me out ?

    Last edited by uaeXuae; Mar 20th, 2008 at 08:55 AM.

  13. #13
    Fanatic Member Clanguage's Avatar
    Join Date
    Jan 2008
    Location
    North Carolina
    Posts
    659

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

    Build your app and you should get all the errors you must fix to get an accurate program.
    CLanguage;
    IF Post = HelpFull Then
    RateMe
    Else
    Say("Shut UP")
    End If
    DotNet rocks
    VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    In that error list errors 2 to 7 are all basically the same. They're saying that you cannot IMPLICITLY convert type X to type Y. Basically you're trying to assign a value of one type to a variable of another. That's generally not allowed with Option Strict On because it may lead to unexpected. This is an example of an implicit conversion:
    vb.net Code:
    1. Dim int As Integer = 100
    2. Dim str As String = int
    The str variable is type String, so it can only refer to a String object. That code assigns an Integer value to it, so the Integer must be implicitly converted to a String. That is not allowed with Option Strict On. You must make the conversion explicitly:
    vb.net Code:
    1. Dim int As Integer = 100
    2. Dim str As String = int.ToString()
    The first error in your list is essentially the same thing but it seems a bit more cryptic. It means that you have a method with a Double parameter passed ByRef and you're passing it an Integer. The problem there is that the original variable is type Integer but in the method you could assign a Double value to the parameter. Because the parameter is ByRef its value is assigned back to the original variable afetr the method completes. That means that you're assigning a Double value to an Integer variable, which we know is not allowed. If you have an Integer then you'd have to convert it to a Double first and then pass that to the method. That way the Double variable can receive the Double value when the method completes.

    It's all very simple. The values you assign to variables must always be the same type as the variable. If they're not then you need to convert or cast the value to the type of the variable, or a compatible type at least. It forces you to think about your data and its type so that you don't accidentally discard important data.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    -Offtopic: If i put all the code in a timer and set time interval to 1 will that be better than having it in the calculation button for faster update? So the moment the NUD controllers have changed their values all calculations are done and results are shown in their tables.

    -Back to Topic:

    Thanx. I can see you have explained the concept in general.

    As for the first error. I debugged but still have no clue.


    Code:
            Dim intPA As Integer
            If Not String.IsNullOrEmpty(Pa.Text) AndAlso Not Pa.Text = "" Then
    
                If Not Double.TryParse(Pa.Text, intPA) Then
                    'Text was entered
                    MessageBox.Show("Text was entered!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Pa.Text = ""
                Else
                    'This checks for blanks in the text boxDim
                    If intPA > 25 Then
                        Pa.Text = 25
                        MessageBox.Show("Pressure angle cannot exceed 25 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Pa.Focus()
                    ElseIf intPA < 0 Then
                        Pa.Text = 0
                        MessageBox.Show("Pressure angle cannot be less than 0 degrees!", "Pressure angle", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Pa.Focus()
                    End If
                End If
            End If
    As for error 2
    Code:
           Pa.Text = 25 
    'related to error1
    As for the errors 4

    Code:
            Dim intPA As Integer
            Integer.TryParse(Pa.Text, intPA)
            resultdp.Text = (intPA * Math.PI) / 180

    As for error 5:
    Diametral_Pitch

    Code:
    Common_Features.Addendum.Text = (1 / (Diametral_Pitch))

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    I didn't explain in general. I explained specifically:
    If you have an Integer then you'd have to convert it to a Double first and then pass that to the method. That way the Double variable can receive the Double value when the method completes.
    Here's your code:
    Code:
            Dim intPA As Integer
            If Not String.IsNullOrEmpty(Pa.Text) AndAlso Not Pa.Text = "" Then
    
                If Not Double.TryParse(Pa.Text, intPA) Then
    Sure enough, you're passing an Integer variable to Double.TryParse, which expects a Double. If you want to parse a Double the pass a Double to the method, not an Integer. If you want to parse an Integer then call Integer.TryParse, not Double.TryParse.

    As for this:
    Code:
    Pa.Text = 25
    I addressed that SPECIFICALLY in my previous reply. What type is the value 25? What type is the Text property? What did I specifically say about assigning Integer values to String variables?

    The same goes for the others. You can't assign something to a String variable or property that isn't a String. CONVERT YOUR VALUES TO STRINGS! I SPECIFICALLY showed you how to do that earlier.
    Last edited by jmcilhinney; Mar 20th, 2008 at 09:56 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Thanx I deleted the code in error 1. Im using a NUD controller so i dont need it.


    I edited error number 4 to
    Code:
    resultpa.Text = CDbl(Pa.Text * Math.PI) / 180

    So now i have 28 errors , all are the same.

    Strict On disallows implicit conversions from 'String'

    What approch do i use to eliminate this error !


  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

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

    The Text value of a control is type String. You can't multiply a String by anything. If the property contains a Double then convert it to a Double, or whatever type is appropriate. You can use CDbl, Double.Parse or Convert.ToDouble to do that. Note though that they will all crash if the String doesn't contain a valid value. If that could happen then you should use Double.TryParse to validate and convert in one step.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    I would love to learn this



    class to store all of the information on a gear (or gears) you can have properties for all of the inputs and readonly properties to hold calculated values (this will be a big help) and you can include methods for calculating things (to store in the read only properties) and functions for getting calculated answers that don't need to be stored in the class itself.
    Then if you make a global instance of this class (declare a variable as <your class name> with a scope of 'Friend') you can access this class via the variable from any form or module in the entire program.
    This would avoid you having to deal with passing information from one form to another from when the "other" form is being opened.

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    How man i fix this ?

    Code:
    Public Class Form1
        Dim Pressure_Angle_Result As Double
        Dim Pressure_angle_Radian As Double
    Dim Diametral_Pitch As Double

    Code:
     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
    Code:
     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.


  21. #21
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

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

    for this one:
    Code:
    Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
    would be:
    Code:
    Pressure_Angle_Result = CDbl((Pressure_angle_Radian * Math.PI) / 180)
    and this:
    Code:
    Common_Features.Addendum.Text = (1 / (Diametral_Pitch))
    would be:
    Code:
    Common_Features.Addendum.Text = CStr(1 / Diametral_Pitch)
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Heres what ive recently been up to :


    Code:
        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


    Im facing another type of error how do i work this one ?

    Nothing Happens But first a dream "Carl Sandburg"

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Im stuck again ... code is fine but calculations arent showing correct.





    Code:
      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
    Nothing Happens But first a dream "Carl Sandburg"

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Its not taking the addendum value whys that ??


    Nothing Happens But first a dream "Carl Sandburg"

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    195

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

    Problem Solved.

    Code:
      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















    Nothing Happens But first a dream "Carl Sandburg"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width