Basic Visual 6: Simple Program for Calculating Trigonometric Values

  • Thread starter Thread starter MotoH
  • Start date Start date
  • Tags Tags
    Visual
AI Thread Summary
A beginner in Visual Basic 6 is developing a program to calculate sine, cosine, and tangent values from an input angle. The code provided includes functions for calculating the Pythagorean theorem and trigonometric values, displaying results in message boxes. The user seeks guidance on displaying results in fraction form and inquires about inverse functions for sine, cosine, and tangent to convert results back into angle measurements. A response clarifies that "As Decimal" refers to memory allocation rather than decimal representation, and it is noted that fractions cannot be directly obtained. Instead, a workaround involving rounding and scaling is suggested. A resource link for further learning is also provided.
MotoH
Messages
51
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:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top