-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Why are you doing it in a click event? Wouldn't it be better to put it in a sub so that it will be done automatically?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
To avoid a lot of conversions you should make a variable to hold your text like
Code:
Dim myVar as Double
myvar = CDbl(Common_Features.Addendum.Text)
Everywhere you use Common_Features.Addendum.Text replace it with myVar you will not have to cast these until you stuff everything back into your labels or textboxes.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Clanguage
Why are you doing it in a click event? Wouldn't it be better to put it in a sub so that it will be done automatically?
BTW ive edited the post right before this one so i dont know if you had a look. Would be great to have it in a sub in the first form. how can i set changes to be done automatically ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Do a search and replace. :)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Ok 1 question before i do so. Why arent those codes integrating ?
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)
Common_Features.Addendum.Text = CDbl(Common_Features.Addendum.Text).ToString
Common_Features.Addendum1.Text = CDbl(Common_Features.Addendum1.Text).ToString
End Sub
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Common_Features.Addendum.Text = (1 / (Diametral_Pitch)).ToString
Common_Features.Addendum1.Text = (Common_Features.Addendum.Text) * 25.4
End Sub
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Code:
Common_Features.Addendum1.Text = CDbl(Common_Features.Addendum1.Text).ToString
not sure what you are trying to do. You convert the Common_Features.Addendum1.Text to a double and you convert it again to a string and then assign the same thing to itself. Tell me what you are trying to do especially with the button1_click event
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
When the calculate button is hit everything is done all tables are filled with numbers but i think i'll do the sub thingy. The one you mentioned earlier. And will let the calculate button job is to hide current form and show next form. Would be better like that.
ive shifted the code to the load handler all of it. and kept the calculate button with the hide/show form code.
Inorder to do a sub what do i need ?
http://aycu28.webshots.com/image/487...1815856_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Code:
Private Function Calculate(ByVal Pa As Double) As Double
Pa = Pa * Math.PI / 180
Return Pa
End Function
Call it this way everytime you need to make the calculation
Code:
result = Calculate(CDbl(pa.Text))
of course result must be a double:thumb:
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Im lost now regarding your last post.
Heres what ive lately done.
Moved all code to here.
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 As Double
Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
Pressure_angle_Radian = CDbl(Pa.Text)
Diametral_Pitch = CDbl(dp.Text)
addendum = CDbl(Common_Features.Addendum.Text)
addendum1 = CDbl(Common_Features.Addendum1.Text)
addendum = 1 / Diametral_Pitch
addendum1 = (addendum * 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
Pinion_Features.Base_Circlep1.Text = (Pinion_Features.Pitch_Radiusp1.Text) * Math.Cos(Pressure_Angle_Result)
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
End Sub
End Class
And still getting the same previous error
http://www.vbforums.com/
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
you need to cast all the text multiplying with a double like this one
Code:
Pinion_Features.Pitch_Radiusp2.Text
it should be
Code:
Pinion_Features.Pitch_Radiusp2.Text = (CDbl((Pinion_Features.Pitch_Radiusp1.Text) * 25.4).ToString
Just like you have done with this one
Code:
CDbl(Common_Features.Dedendum.Text)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
That's because there's nothing in Common_Features.Addendum.Text
It's empty.
You can't make a number out of an empty String.
This line:
Velocity_Ratio = vr.Text
Is going to error too, because Velocity_Ratio is a Double, not a String. Same with the ones under it.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
but the program halts on at the very start where is the error in that picture
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Thanks. heres what i want to say.
Dim Addendum as double ofcourse.
addendum = 1 / Diametral_Pitch
Then send the result over to that form
addendum = CDbl(Common_Features.Addendum.Text)
I have the idea but cant write that code :S
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Common_Features.Addendum.Text = addendum.ToString
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I have cleaned your code a little so that you do not have to make so many conversions.
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, Root_Radiusp1, Whole_Depthp1, Working_Depthp1 As Double
Dim Pressure_Angle_Result, Outer_Circlep1 As Double
Dim Pressure_angle_Radian, Pitch_Radiusp1, Base_Circlep1 As Double
Dim addendum, addendum1, dedendum, clearance, pinion1 As Double
Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
Pressure_angle_Radian = CDbl(Pa.Text)
Diametral_Pitch = CDbl(dp.Text)
addendum = CDbl(Common_Features.Addendum.Text)
addendum1 = CDbl(Common_Features.Addendum1.Text)
dedendum = CDbl(Common_Features.Dedendum.Text)
clearance = CDbl(Common_Features.clearance.Text)
pinion1 = CDbl(Pinion_Features.pinion1.Text)
Pitch_Radiusp1 = CDbl(Pinion_Features.Pitch_Radiusp1.Text())
Base_Circlep1 = CDbl(Pinion_Features.Base_Circlep1.Text)
Outer_Circlep1 = CDbl(Pinion_Features.Outer_Circlep1.Text)
Root_Radiusp1 = CDbl(Pinion_Features.Root_Radiusp1.Text)
Whole_Depthp1 = CDbl(Pinion_Features.Whole_Depthp1.Text)
Working_Depthp1 = CDbl(Pinion_Features.Working_Depthp1.Text)
addendum = 1 / Diametral_Pitch
addendum1 = (addendum * 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 = (dedendum * 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 = (clearance * 25.4).ToString
Velocity_Ratio = CDbl(vr.Text)
gear = CDbl(gearteeth1.Text)
Pinion_Features.pinion1.Text = (Math.Floor(Velocity_Ratio * gear)).ToString
Pinion_Features.Pitch_Radiusp1.Text = ((pinion1 / Diametral_Pitch) / 2).ToString
Pinion_Features.Pitch_Radiusp2.Text = (Pitch_Radiusp1 * 25.4).ToString
Pinion_Features.Base_Circlep1.Text = (Pitch_Radiusp1 * Math.Cos(Pressure_Angle_Result)).ToString
Pinion_Features.Base_Circlep2.Text = (Base_Circlep1 * 25.4).ToString
Pinion_Features.Outer_Circlep1.Text = (dedendum + Pitch_Radiusp1).ToString
Pinion_Features.Outer_Circlep2.Text = (Outer_Circlep1 * 25.4).ToString
Pinion_Features.Root_Radiusp1.Text = (Pitch_Radiusp1 - dedendum).ToString
Pinion_Features.Root_Radiusp2.Text = (Root_Radiusp1 * 25.4).ToString
Pinion_Features.Whole_Depthp1.Text = (addendum + dedendum).ToString
Pinion_Features.Whole_Depthp2.Text = (Whole_Depthp1 * 25.4).ToString
Pinion_Features.Working_Depthp1.Text = (addendum * 2).ToString
Pinion_Features.Working_Depthp2.Text = (Working_Depthp1 * 25.4).ToString
End Sub
the majority of the casts were wrong anyway.
hope this helps:) :)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
WOW THANX ! I wish i looked at your post before i do everything myself anways heres what ive done. Yours is TIDY and NEAT. love it. tell me what you think of mines.
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
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
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Do you get any error? Do you get the right answers when you run it?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Im facing another type of error how do i work this one ?
http://aycu01.webshots.com/image/485...4566960_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Add ".text" to your pitch_radius1
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
GREAT NOTICE. ive been doing this again and again how funny LOOOOOOOOOOOL
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
No problem. Your app is looking better by the minute. By the time you are finished this project you will be a pro:):):)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
after i added .text i tried the program why does it read NaN what does that mean ?
http://img228.imageshack.us/img228/6362/readingzv4.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Remember, study the examples given and understand them. You'll be pro in no time. :D
NaN stands for "Not a Number"
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I got it :
Why do i have to re-write those three lines again i want it to be there by default.
http://aycu15.webshots.com/image/482...7862596_rs.jpg
Where shall i put them ?
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
You don't need them twice, but you must make sure you have values in Pa and gearteeth1 or you'll get NaN. You must make sure Pa, gearteeth1 and all your other textboxes have values in them BEFORE you make this form visible.
I'm wondering if we should teach you about how to use Properties since you're dragging data from other forms improperly.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Youcan safely remove the 2nd and the 3rd lines. You need to keep the 1st one though
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
i do have values in both pa and geerteeth1 but it leads to NaN. Those three lines must be above the desired code. So how can i make it common for the whole form.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Clanguage
Youcan safely remove the 2nd and the 3rd lines. You need to keep the 1st one though
The first one is already there. Actually all 3 lines are there. I repeated them again but set them on top of the desired code.
http://aycu05.webshots.com/image/463...1963140_rs.jpg
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
I think i shall place the three lines after the DIM immediately to that theyll be there for all . thats the only workaround i can see.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Yes do the assignment early.
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Im stuck again ... code is fine but calculations arent showing correct.
http://aycu37.webshots.com/image/465...9344826_rs.jpg
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
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Its not taking the addendum and dedendum values This is quite odd since ive set them all to double whys that ??
http://www.vbforums.com/
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Quote:
Originally Posted by Clanguage
I have cleaned your code a little so that you do not have to make so many conversions.
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, Root_Radiusp1, Whole_Depthp1, Working_Depthp1 As Double
Dim Pressure_Angle_Result, Outer_Circlep1 As Double
Dim Pressure_angle_Radian, Pitch_Radiusp1, Base_Circlep1 As Double
Dim addendum, addendum1, dedendum, clearance, pinion1 As Double
Pressure_Angle_Result = (Pressure_angle_Radian * Math.PI) / 180
Pressure_angle_Radian = CDbl(Pa.Text)
Diametral_Pitch = CDbl(dp.Text)
addendum = CDbl(Common_Features.Addendum.Text)
addendum1 = CDbl(Common_Features.Addendum1.Text)
dedendum = CDbl(Common_Features.Dedendum.Text)
clearance = CDbl(Common_Features.clearance.Text)
pinion1 = CDbl(Pinion_Features.pinion1.Text)
Pitch_Radiusp1 = CDbl(Pinion_Features.Pitch_Radiusp1.Text())
Base_Circlep1 = CDbl(Pinion_Features.Base_Circlep1.Text)
Outer_Circlep1 = CDbl(Pinion_Features.Outer_Circlep1.Text)
Root_Radiusp1 = CDbl(Pinion_Features.Root_Radiusp1.Text)
Whole_Depthp1 = CDbl(Pinion_Features.Whole_Depthp1.Text)
Working_Depthp1 = CDbl(Pinion_Features.Working_Depthp1.Text)
addendum = 1 / Diametral_Pitch
addendum1 = (addendum * 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 = (dedendum * 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 = (clearance * 25.4).ToString
Velocity_Ratio = CDbl(vr.Text)
gear = CDbl(gearteeth1.Text)
Pinion_Features.pinion1.Text = (Math.Floor(Velocity_Ratio * gear)).ToString
Pinion_Features.Pitch_Radiusp1.Text = ((pinion1 / Diametral_Pitch) / 2).ToString
Pinion_Features.Pitch_Radiusp2.Text = (Pitch_Radiusp1 * 25.4).ToString
Pinion_Features.Base_Circlep1.Text = (Pitch_Radiusp1 * Math.Cos(Pressure_Angle_Result)).ToString
Pinion_Features.Base_Circlep2.Text = (Base_Circlep1 * 25.4).ToString
Pinion_Features.Outer_Circlep1.Text = (dedendum + Pitch_Radiusp1).ToString
Pinion_Features.Outer_Circlep2.Text = (Outer_Circlep1 * 25.4).ToString
Pinion_Features.Root_Radiusp1.Text = (Pitch_Radiusp1 - dedendum).ToString
Pinion_Features.Root_Radiusp2.Text = (Root_Radiusp1 * 25.4).ToString
Pinion_Features.Whole_Depthp1.Text = (addendum + dedendum).ToString
Pinion_Features.Whole_Depthp2.Text = (Whole_Depthp1 * 25.4).ToString
Pinion_Features.Working_Depthp1.Text = (addendum * 2).ToString
Pinion_Features.Working_Depthp2.Text = (Working_Depthp1 * 25.4).ToString
End Sub
the majority of the casts were wrong anyway.
hope this helps:) :)
BTW i copied - pasted your code and heres what i got..
http://aycu25.webshots.com/image/472...2464844_rs.jpg
So i pasted mines back..
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
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
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
http://www.vbforums.com/
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Moving on to the Construction Circles..
http://aycu17.webshots.com/image/479...5239500_rs.jpg
This is the function of the program But wheres the hard part ? The invisible calculations. First each the gear and the pinion have four construction Circles.
Lets see how we obtained the gear Construction Circles and the Pinion Construction Circles.
This is the tough part all done invisible but i dont know how and still not sure how to check the results. since i wont see anything from it.
http://aycu17.webshots.com/image/477...8970143_rs.jpg
The values that go 5 , 10 , 15, 20 ...... 360 are fixed since a circle is 360 Degrees.
Calculations are done like that:
http://aycu11.webshots.com/image/486...9233667_rs.jpg
Similary for the pinion
http://aycu32.webshots.com/image/471...0471977_rs.jpg
Picture3
There are 2 outputs
Output for the gear with the 4 Construction Circles
Output for the pinion 4 Construction Circles:
Ther Picture below is the picture of the pinion with the 4 construction Circles.
http://aycu05.webshots.com/image/489...2493086_rs.jpg
This is enuf for now. I want one button to show The gear Construction Circles and another to show the Pinion Constrcution circles.
I'll be more than happy to Continue Explaining the objectives after i achieve this one with the help of you guys.
Summary.
there are two tables one for the Gear and another for the pinion ( A pinion is a a gear but smaller in size ).
I want to generate a construction circle in where that Construction Circle represents the Gear and another one to represent the pinion .
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Once again to clarify things better :
As in first Picture I'll have to generate a code
to make a fixed invisible colum
For i = 0 to 360
Step 5
http://aycu15.webshots.com/image/472...0924840_rs.jpg
Then Each time it itterates the value gets multiplied by Pi and divided by 180
and stored in a similar way like excel.
http://aycu37.webshots.com/image/497...8128910_rs.jpg
As for the third Picture weve got 4 circles
Pitch
base
Outer
Root
and each one has X, Y
Equations are the same for all 4 circles
the only thing that differs is that.
For example lets consider the Base Circle as shown in 3d picture.
X1 = Base Circle value ( same one used for Y) * Cos ( The stored value from the second picture)
X2 = ......
X360 = .....
Y1 = Base Circle Value * Sin ( The stored Value from the second Picture)
Y2=.....
Y360=......
The remaining three construction circles are built in the same concept and same equation but the only one difference is the for pitch circle we use the value from the table of pitch
in Root we use the value assigned for root and so on.
Once weve got the code for all 4 circles. we can draw the circle as a representation of that table.
http://aycu13.webshots.com/image/487...5060223_rs.jpg
Any help would be welcomed :-)
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
Ok, time for you to look into how to construct a For-Next loop and use an Array.
An Array is a whole stack of variables with the same name. You use the equivalent of a sub-script to keep them separated. It's like a list. You have an easy problem because you know ahead of time how big your list is going to be: (360 / 5) = 72.
So, you make an array this big:
Dim myArray(72) as Double
This is a list of 73 numbers (73 because it starts counting at 0). They work just like any other variable, except you have to specify which one of the list you're reading/writing to:
myArray(3) = 54.665
Now, you 're NOT going to write out 73 lines of code and do the SAME calculation on each one... you're going to use a loop that is going to loop 73 times and fill in each one for you. Here's your table using a loop and 8 arrays with 73 elements each:
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Make your arrays
Dim BaseX(72) As Double
Dim BaseY(72) As Double
Dim PitchX(72) As Double
Dim PitchY(72) As Double
Dim RootX(72) As Double
Dim RootY(72) As Double
Dim OuterX(72) As Double
Dim OuterY(72) As Double
'You're filling in these 4 from your other form.
Dim Rbg_mm As Double
Dim Rpg_mm As Double
Dim Rrg_mm As Double
Dim Rog_mm As Double
'These are temporary variables to make the calculations easier.
Dim dblSinTemp As Double
Dim dblCosTemp As Double
For i As Integer = 0 To 360 Step 5
dblSinTemp = Math.Sin((i * Math.PI) / 180.0)
dblCosTemp = Math.Cos((i * Math.PI) / 180.0)
BaseX(i \ 5) = Rbg_mm * dblCosTemp
BaseY(i \ 5) = Rbg_mm * dblSinTemp
PitchX(i \ 5) = Rpg_mm * dblCosTemp
PitchY(i \ 5) = Rpg_mm * dblSinTemp
RootX(i \ 5) = Rrg_mm * dblCosTemp
RootY(i \ 5) = Rrg_mm * dblSinTemp
OuterX(i \ 5) = Rog_mm * dblCosTemp
OuterY(i \ 5) = Rog_mm * dblSinTemp
Next
'That's it.
End Sub
End Class
-
Re: [2008] Please help me Build a Visual Basic Program from this Excel file
WoW you seem youve spent some time reading my excel file. I can tell from your code. THANX MAN will look into it attempt the solution and post back if i have any trouble. THANX again :-)