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
 
Edit:Frankly Speaking Even if i read this book till tommorow. I wont find a solution to this thread. Since you advised me to read the book and ignore like 10 chapters. The rest is just useless. Thats why i hate reading VB books. The only way to learn is by asking and making mistakes. Even if it takes time but at least I'll learn something from my mistakes. Another thing that book is regarding .Net 2005 im using .Net 2008. I hope somone sends me a URL that perfectly matches my case or help me code this part of the project.

It doesn't matter the version. The fact is you don't know hardly anything about programming and are expecting others to answer every little question you have instead of learning anything about how controls work, events, delegates and classes. You are asking questions that simply reading a book about development would answer for you if you took the chance to actually learn how to do it instead of expecting others to basically hand you the answers.
 
You are asking questions that simply reading a book about development would answer for you if you took the chance to actually learn how to do it instead of expecting others to basically hand you the answers.

Would love to see you help me on this one. ;)


Man i know you want me to learn it the hard way. I have 2 weeks. During the week im at the universities i work in VB 3 days a week. I also have weekly & midterm exams next week and the week after. I really dont have time for reading a book. Since the project aint a big deal and have many repetitive things in common. For instance if i know how to do it for one im pretty sure i'll know how to do the rest 3 buttons because its the same procedure. I can try as i tried a while ago. Any help would be appreciated. :).
 
Got it to work
All code was set in Form1
In the Calculate Button i added this



VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Diametral_Pitch = dp.Text
        second.Label1.Text = Form1.Diametral_Pitch
        second.Show()
        Me.Hide()

    End Sub

now back to original post i'll try to do the same.


VB.NET:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Diametral_Pitch = dp.Text
        Common_Features.Distance_Center.Text = (1 / (Form1.Diametral_Pitch))
        second.Show()
        Me.Hide()

    End Sub
 
Last edited:
VB.NET:
        If Diametral_Pitch < 0 Then
            Common_Features.Dedendum.Text = (1.25 / Diametral_Pitch).ToString
        ElseIf Diametral_Pitch > 0 Then
            Common_Features.Dedendum.Text = ((1.2 / Diametral_Pitch) + 0.002).ToString
        End If

The only problem is that the answer i get from VB is 0.302 while the answer i get when i use my calculater is 0.3125

The equation is as follows 1.25/4 So why am i getting 0.302 ?
 
VB.NET:
        If Diametral_Pitch < 0 Then
            Common_Features.Dedendum.Text = (1.25 / Diametral_Pitch).ToString
        ElseIf Diametral_Pitch > 0 Then
            Common_Features.Dedendum.Text = ((1.2 / Diametral_Pitch) + 0.002).ToString
        End If

The only problem is that the answer i get from VB is 0.302 while the answer i get when i use my calculater is 0.3125

The equation is as follows 1.25/4 So why am i getting 0.302 ?

Because the equation you are getting the answer for is (1.2 / 4) + .002, not 1.25 / 4.
 
Your right it was suppossed to be if fiametral pitch > 20 not ">0". Thats why i was a bit confused. Anyways im over that problem. I have another one :s


Code that i wrote:

VB.NET:
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

VB.NET:
   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 ?

2004140167460629062_rs.jpg
 
(CDbl(Common_Features.Dedendum.Text) + CDbl(Pinion_Features.Pitch_Radius1.Text)).ToString

It adds Now what does CDbl actually does ??

I think i was doing text's together !

"Hello" + "World" = HelloWorld

2004801219719440538_rs.jpg
 
I went to project properties and set Option Strict to On


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

upoi1.jpg



heres my code:


VB.NET:
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



VB.NET:
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_Radiusp1.Text = (Pinion_Features.pinion1.Text / Diametral_Pitch).ToString / 2
        Pinion_Features.Pitch_Radiusp2.Text = (Pinion_Features.Pitch_Radiusp1.Text * 25.4).ToString

        Pressure_Angle = resultdp.Text
        Pinion_Features.Base_Circlep1.Text = (Pinion_Features.Pitch_Radiusp1.Text) * Math.Cos(Pressure_Angle)
        Pinion_Features.Base_Circlep2.Text = (Pinion_Features.Base_Circlep1.Text * 25.4).ToString


        Pinion_Features.Outer_Circlep1.Text = CDbl(Common_Features.Dedendum.Text) + CDbl(Pinion_Features.Pitch_Radiusp1.Text).ToString
        Pinion_Features.Outer_Circlep2.Text = CDbl(Pinion_Features.Outer_Circlep1.Text * 25.4).ToString

        Pinion_Features.Root_Radiusp1.Text = CDbl(Pinion_Features.Pitch_Radiusp1.Text) - CDbl(Common_Features.Dedendum.Text).ToString
        Pinion_Features.Root_Radiusp2.Text = CDbl(Pinion_Features.Root_Radiusp1.Text * 25.4).ToString

        Pinion_Features.Whole_Depthp1.Text = CDbl(Common_Features.Addendum.Text) + CDbl(Common_Features.Dedendum.Text).ToString
        Pinion_Features.Whole_Depthp2.Text = CDbl(Pinion_Features.Whole_Depthp1.Text * 25.4).ToString

        Pinion_Features.Working_Depthp1.Text = CDbl(Common_Features.Addendum.Text * 2).ToString
        Pinion_Features.Working_Depthp2.Text = CDbl(Pinion_Features.Working_Depthp1.Text * 25.4).ToString



        second.Show()
        Me.Hide()

    End Sub
 
You know that book you have been told to read multiple times now? Yeah, try reading it, there is a reason you have been told by multiple people to read a book on this stuff. Specifically chapter 2, there is a reason it is at the beginning of the book and you were told to read it...
 
You know that book you have been told to read multiple times now? Yeah, try reading it, there is a reason you have been told by multiple people to read a book on this stuff. Specifically chapter 2, there is a reason it is at the beginning of the book and you were told to read it...




Advise taken into consideration. This is what i was willing to know. 1024 pages will take long time , its like " Here grab a book read , If you still dont get it theres another author who presents its much better try the other one"

Since youve directed me to chapter 2 straight a way. I will explore that chapter. At the mean time >>> Waiting for someone else to jump in and simply explain the error messages :p.
 
As for the first error. I debugged but still have no clue.


VB.NET:
        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
VB.NET:
       Pa.Text = 25 
'related to error1

As for the errors 4

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


As for error 5:
Diametral_Pitch

VB.NET:
Common_Features.Addendum.Text = (1 / (Diametral_Pitch))
 
I'd like to step in to make a suggestion. While reading the book, look into reading the chapter on making your own classes. In your gear calculation program (which spans 9 threads on this forum alone) you might want to consider making things a whole lot easier by making a 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.
 
Thanks what chapter specifically talks about the C class construction ?
 
Back
Top