Basic Visual 6: Simple Program for Calculating Trigonometric Values

  • Thread starter Thread starter MotoH
  • Start date Start date
  • Tags Tags
    Visual
Click For Summary
SUMMARY

The discussion focuses on creating a simple Visual Basic 6 program to calculate trigonometric values, specifically sine, cosine, and tangent. The user shares code snippets for calculating the hypotenuse using the Pythagorean theorem and obtaining trigonometric values from user input. Key questions include how to display results in fraction form and whether inverse trigonometric functions exist in Visual Basic 6. The consensus is that Visual Basic 6 does not natively support fraction outputs, and users can utilize rounding techniques to approximate fractions.

PREREQUISITES
  • Basic understanding of Visual Basic 6 programming
  • Familiarity with trigonometric functions and their applications
  • Knowledge of data types in Visual Basic, specifically "As Decimal"
  • Experience with user interface elements like TextBox and MsgBox in Visual Basic 6
NEXT STEPS
  • Research how to implement inverse trigonometric functions in Visual Basic 6
  • Explore methods for displaying numerical results as fractions in Visual Basic
  • Learn about the Math.Round function and its applications in Visual Basic 6
  • Investigate additional resources for Visual Basic programming, such as VBForums
USEFUL FOR

Beginner programmers, students learning Visual Basic 6, and anyone interested in implementing trigonometric calculations in their applications.

MotoH
Messages
53
Reaction score
2
Hi, I am a beginner at Visual Basic 6! I am trying to make a simple program that will allow you to enter an angle, and receive the sine, cosine, and tangent values.

the code:
Code:
Public Class Form1
    ' Imports System.Math
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim A As Double = TextBox1.Text
        Dim B As Double = TextBox2.Text
        MsgBox((A ^ 2 + B ^ 2) ^ (1 / 2))

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim A As Double = TextBox3.Text
        Dim C As Double = TextBox4.Text
        MsgBox((C ^ 2 - A ^ 2) ^ (1 / 2))

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim A As Decimal = TextBox5.Text
        
        MsgBox("cos" & " " & Math.Cos(A))
        MsgBox("sin" & " " & Math.Sin(A))
        MsgBox("tan" & " " & Math.Tan(A))



    End Sub
End Class
As you can see this is very rudimentary stuff.

The first part of the code is for the Pythagorean Theorem knowing A and B, or AorB and C.
The second part will give me the sine, cosine and tangent of an angle in a message box in decimal form.

The questions I have:
Is there a command that will make the answers appear in fraction form? I am assuming this will replace the "As Decimal" but I can't find anything in the book I have or on the microsoft website.

Are there inverse sine, cosine and tangent commands? So I can turn the fraction back into the angle (in radians or degrees)

Please forgive me if it is very simple! I am still learning!
 
Technology news on Phys.org
MotoH said:
Is there a command that will make the answers appear in fraction form? I am assuming this will replace the "As Decimal" but I can't find anything in the book I have or on the microsoft website.

Are there inverse sine, cosine and tangent commands? So I can turn the fraction back into the angle (in radians or degrees)

Please forgive me if it is very simple! I am still learning!

As Decimal does not mean decimal but it specifies the amount of memory that should be allocated I believe.

No you can NOT get in fractions unless you do something like Math.Round .. to 2 digit places (0.35) and then multiple by 100 by get the numerator (35) and provide 100 as denominator (35/100)
 
Last edited:

Similar threads

Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K