Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

I am in the process of rewriting a few windows apps that I wrote about 20 years ago in order to have them work better on our newer computers. It has been a while since I have done anything in VB and it did not take long before I came to an impasse. Below is the code I have started on for a radius generator for our toolmakers to give them step over values so that they can generate radiuses on the grinder. I know that the code is rudimentary but I am starting off very simple and straight forward in order to try and keep problems to a minimum. I am not getting the correct return for the "angle = Math.Asin(temp1)" function. Would someone mind taking a look at it for me? I am trying to get reacquainted with VB before I try and attempt writing hooks.

 

 

Dim wheel_rad As Double

Dim part_rad As Double

Dim cusp As Double

Dim side_c As Double

Dim side_b As Double

Dim side_a As Double

Dim temp1 As Double

Dim angle As Double

part_rad = TextBox1.Text

wheel_rad = TextBox2.Text

cusp = TextBox3.Text

side_c = wheel_rad

side_b = wheel_rad - cusp

side_c = side_c * side_c

side_b = side_b * side_b

side_a = side_c - side_b

side_a = Math.Sqrt(side_a)

temp1 = side_a / part_rad

TextBox4.Text = temp1

angle = Math.Asin(temp1)

TextBox5.Text = angle

Link to comment
Share on other sites

From a very quick look at the MSDN website .. it appears that the function returns a value in Radians..

 

 

The following is from the MSDN website ..

'DeclarationPublic Shared Function Asin ( _	d As Double _) As Double

 

Parameters d Type: System.Double

--------------------------------------------------------------------------------------

A number representing a sine, where d must be greater than or equal to -1, but less than or equal to 1.

 
 
 
Return Value Type: System.Double
-----------------------------------------------------------------------------------
An angle, θ, measured in radians, such that -π/2 θ π/2
-or-
NaN if d < -1 or d > 1 or d equals NaN.
 

 

Remarks

 

A positive return value represents a counterclockwise angle from the x-axis; a negative return value represents a clockwise angle.

Multiply the return value by 180/Math.PI to convert from radians to degrees.

Link to comment
Share on other sites
Guest MTB Technical Services

Your code is a bit verbose and could be simplified greatly.

You don't need all the variables you have declared.

Keep in mind that every declaration allocates memory.

 

You also should be validating that the data entered in a field is actually numeric or evaluates to a numeric value.

 

You'll also want to add error handling to our procedures.

 

You'll need to convert radians to degrees.

Here's an old VB Module i wrote that should help you.

https://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=28209&lngWId=1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...