|
-
Jan 30th, 2003, 01:27 PM
#1
Thread Starter
Addicted Member
Trigometric Functions
Okay,
I have a sheet with the sine, cosine and tangent of the angesl 1 - 90 and i need to save it as a text file. Instead of typing them into the computer i decided to write a program to do it, what seemed to make a lot of sense. But it appears that vb's sin, cos, & tan functions are screwed up. For ex: vb says the sine of 1 is .8414..., while my sheet (and calculator) say .0174.... Any ideas?
Thanks,
-George
-
Jan 30th, 2003, 01:34 PM
#2
Stuck in the 80s
My guess is that VBs functions are in radian mode, and you are entering degrees. I'm not sure how to fix it, unless you want to enter radians instead of degrees.
-
Jan 30th, 2003, 01:37 PM
#3
Stuck in the 80s
You could do this:
VB Code:
MsgBox Format(Sin(45 * (3.14159 / 180)), "#.######")
And just replace 45 for the angle you want. That should give you a close enough number.
-
Jan 30th, 2003, 02:45 PM
#4
Lively Member
You can highlight Sin, Cos or Tan and hit the F1 key which will shortcut you to help on the function. It will tell you to multipy the value by PI/180 to convert radians to degrees and 180/PI to convert degrees to radians. The returned value from the above VB functions is in radians.
-
Jan 30th, 2003, 03:30 PM
#5
Stuck in the 80s
Originally posted by rba4321
You can highlight Sin, Cos or Tan and hit the F1 key which will shortcut you to help on the function. It will tell you to multipy the value by PI/180 to convert radians to degrees and 180/PI to convert degrees to radians. The returned value from the above VB functions is in radians.
That's what I did in the code above my post. If he doesn't have MSDN, F1 isn't going to do him any good.
-
Jan 30th, 2003, 10:27 PM
#6
Try this:
VB Code:
Dim i As Integer
Private Sub Command1_Click()
For i = 1 To 90
Open App.Path & "\CST.txt" For Append As #1
Print #1, "Cosine of" & " " & i & " =" & Format(Cos((i) * (3.14159 / 180)), "#.######")
Print #1, "Sin of" & " " & i & " =" & Format(Sin((i) * (3.14159 / 180)), "#.######")
Print #1, "Tan of" & " " & i & " =" & Format(Tan((i) * (3.14159 / 180)), "#.######")
Close #1
Next i
End Sub
I just used THs idea to print the data to a file.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 30th, 2003, 11:30 PM
#7
Stuck in the 80s
Originally posted by Nightwalker83
Try this:
I just used THs idea to print the data to a file.
Instead of opening the file 90 times, why not:
VB Code:
Dim i As Integer
Private Sub Command1_Click()
Open App.Path & "\CST.txt" For Output As #1
For i = 1 To 90
Print #1, "Cosine of" & " " & i & " =" & Format(Cos((i) * (3.14159 / 180)), "#.######")
Print #1, "Sin of" & " " & i & " =" & Format(Sin((i) * (3.14159 / 180)), "#.######")
Print #1, "Tan of" & " " & i & " =" & Format(Tan((i) * (3.14159 / 180)), "#.######")
Next
Close #1
End Sub
-
Jan 31st, 2003, 12:33 AM
#8
Originally posted by The Hobo
Instead of opening the file 90 times, why not:
VB Code:
Dim i As Integer
Private Sub Command1_Click()
Open App.Path & "\CST.txt" For Output As #1
For i = 1 To 90
Print #1, "Cosine of" & " " & i & " =" & Format(Cos((i) * (3.14159 / 180)), "#.######")
Print #1, "Sin of" & " " & i & " =" & Format(Sin((i) * (3.14159 / 180)), "#.######")
Print #1, "Tan of" & " " & i & " =" & Format(Tan((i) * (3.14159 / 180)), "#.######")
Next
Close #1
End Sub
Oops I put next and close around the wrong way.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|