Tracker
 ASP PHP JavaScripts MySQL MS Access MSSQL VISUAL BASIC Subjects/Titles Post Text/Content
HOME    TRACKER    Visual Basic

## For those of you who have ever tried to use the Sin(),Cos() or Tan() functions. does anyone know why it takes the angle in Radians only, this has been quite anoying for me at times because the conversion of Degrees to Radians uses Pi.Even if I use Pi to a ridiculous accuracy it still comes out slightly off. For example Sin(180 degrees) = 0 and 180 degrees in Radians is 2*Pi so in VB if I write Sin(2*Pi) i should get 0 but I don't doesn't matter if I split Pi up into 2 "Double" variables (30 decimal places, I think) it still comes out off. Wouldn't it have been easier to have made the functions to accept Degrees?

Converting Radians To Degrees, How Can I Do It?
I need to be able to change the answer which is in radians to degrees.

VB Code:
lblSinValue.Caption = "The Sine Value of " & txtAngle & " is " & Math.Sin(txtAngle)

That is my current code for it. I need to make it in degrees but I cant figure it out. I have searched other threads to no avail. All help is greatly appreciated.

Sin && Cos In VB, Degrees/Radians
I have a program for which I need to calculate the Sin and Cos of certain angles.

The angles are represented in degrees.

However, when I put Sin(60) it gives me -0.3048....., which appears to be in radians instead of degrees.
I want it to be in degrees. ie: Sin(60) should be equal to Sqr(3)/2
(I actually want to do more complicated degrees, so I can't use exact values)

Is there any way to make VB calculate Sin using degrees instead of Radians?
Or alternatively, someone told me that to get it into degrees you would do Sin(180 * degree/ pi). However, how do I represent pi visual basic?

Any help would be much appreciated.

Hi again....
I'm making a triangle calculator and I thereby use sin, cos and tan.
The results is in radians,but I want them in Deg, so i multiply with 180 and divide with pi, but now the results equals 0 and angle a is 90 deg!!?!?!?

VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Pi = 3.1415926535897931    End Sub     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)      End Sub     Private Sub cmdBeregn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBeregn.Click        VinkelA = txtVinkelA.Text        VinkelB = txtVinkelB.Text        SideA = txtSidea.Text        SideB = txtSideb.Text        SideC = txtSidec.Text                 'Kontroller at der er de tilstrækkelige vinkler/sider        If (txtVinkelA.Text = 0 And txtVinkelB.Text = 0) And _        (txtSidea.Text = 0 And txtSideb.Text = 0 Or txtSideb.Text = 0 And _        txtSidec.Text = 0 Or txtSidea.Text = 0 And txtSidec.Text = 0) Then            MsgBox("Der er ikke de tilstrækkelige sider/vinkler til at fortsætte!", MsgBoxStyle.Exclamation, _            "Fejl!")         End If         'Start beregninger.        'Tjek at Vinkel A findes. Hvis ikke findes den ud fra Vinkel B og Vinkel C.        If VinkelA = 0 Then            VinkelA = 180 - (90 + VinkelB)        End If          'Vinkel B kendes ikke, så Vinkel A vil blive fundet ud fra siderne.        If Not SideA = 0 And SideC = 0 Then            VinkelA = Math.Asin(SideA / SideC)        Else             If Not SideA And SideB = 0 Then                VinkelA = Math.Atan(SideA / SideB)             Else                If Not SideB And SideC = 0 Then                    VinkelA = Math.Acos(SideB / SideC)                 End If            End If        End If        'Find side a, hvis denne ikke allerede findes:        If SideA = 0 Then            If Not SideB = 0 Then                SideA = SideB * Math.Tan(VinkelA)            Else                SideA = SideC * Math.Sin(VinkelA)                If Not SideB And SideC = 0 Then                    SideA = Math.Sqrt(SideC ^ 2 - SideB ^ 2)                End If             End If        End If         'Find side b. hvis denne ikke allerede findes:         If SideB = 0 Then            If Not SideA = 0 Then                SideB = SideA / Math.Tan(VinkelA)            Else                SideB = SideC * Math.Cos(VinkelA)                If Not SideA And SideC = 0 Then                    SideB = Math.Sqrt(SideC ^ 2 - SideA ^ 2)                 End If             End If        End If         'Find side c, hvis denne ikke allerde findes:         If SideC = 0 Then            If Not SideA = 0 Then                SideC = SideA * Math.Sin(VinkelA)            Else                SideC = Math.Sqrt(SideA ^ 2 + SideB ^ 2)             End If        End If         SideA = SideA * 180 / Pi        SideB = SideB * 180 / Pi        SideC = SideC * 180 / Pi        SideB = SideB * 180 / Pi        VinkelA = VinkelA * 180 / Pi        VinkelB = VinkelB * 180 / Pi         lblDone.Visible = True        lblSidea.Visible = True        lblSideb.Visible = True        lblSidec.Visible = True         lblVinkelA.Visible = True        lblVinkelB.Visible = True         lblSidea.Text = "Side a: " & SideA        lblSideb.Text = "Side b: " & SideB        lblSidec.Text = "Side c: " & SideC         lblVinkelA.Text = "Vinkel A: " & VinkelA        lblVinkelB.Text = "Vinkel B: " & VinkelB         End Sub     Private Sub cmdNulstil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNulstil.Click        'Nulstil alle felter        txtSidea.Text = 0        txtSideb.Text = 0        txtSidec.Text = 0        txtVinkelA.Text = 0        txtVinkelB.Text = 0     End SubEnd Class

Im trying to get the Log() of the number in VB. After messing with the formula for a while I realized I could not get the same answer on the simplist number as I would with the M.S. calculator. It was then I figured out that by default, the Deg. is checked in calculator scientific view, when I checked Radians and ran my numbers I got the same answer as VB was giving me. What that tells me is that VB uses the Radians to give the Log() of a number. What I want to do is get the Degrees answer in VB, (the same answer I get in calculator with Degrees.)
Can anyone help?

Here is the code if it helps

Code:

Dim gain1 As Single
Dim gain2 As Single
Dim gain3 As Single
gain1 = 1.0666 * 1.0666 * 12 * .2126
gain2 = Log(gain1) ' Log of gain1 should be .4627 but its not in VB
gain3 = 11.8 + (10 * gain2)
t_gain.Text = gain3 ' this number should be 16.42 in VB but VB shows something very different

Thanks

Is there a way to set your vb program to work in degrees rather than radians?

Would make my program a lot easier to understand, when using cos and sin of angles!

m trying to get the Log() of the number in VB. After messing with the formula for a while I realized I could not get the same answer on the simplist number as I would with the M.S. calculator. It was then I figured out that by default, the Deg. is checked in calculator scientific view, when I checked Radians and ran my numbers I got the same answer as VB was giving me. What that tells me is that VB uses the Radians to give the Log() of a number. What I want to do is get the Degrees answer in VB, (the same answer I get in calculator with Degrees.)
Can anyone help?

Here is the code if it helps

VB Code:
Dim gain1 As Single Dim gain2 As Single Dim gain3 As Single gain1 = 1.0666 * 1.0666 * 12 * .2126 gain2 = Log(gain1) ' Log of gain1 should be .4627 but its not in VB gain3 = 11.8 + (10 * gain2) t_gain.Text = gain3 ' this number should be 16.42 in VB but VB shows something very different

Thanks

I'm making a pi calculator that uses the formula:

Pi = Sine(180/n)*n; Where n is a lage number less than infinity. the code looks like this:

Code:
Private Sub cmdCalc_Click()
Dim Value As Double
Dim Number As Integer

Number = txtN.Text
Value = 180 / Number
End Sub
However the Sine function in vb is expressed in Radians not Degrees rendering the formula useless. How do I get it to calculate using degrees?

Also, vb limits its numerical answers to about 20 decimal places. How can I program it to go to 30, 50, 100 or more places? (bonus if the user can change this number!). Thanks.

Trig Needed-Sin(angle) From Radians To Degrees
I'm making a program to help with physics problems. The reason I'm making this is to just challenge myself and make something useful. However the Projectial Motion problems use sin, cos, and tan in degrees instead of radians.

What I want is best descibed with the use of the windows Calculator - RUN>Calc - set in sciencific mode. If you put in 10 set it to Radians and hit sin, cos, or tan you get what VB gives back but what I need for my calculations is 10 set to Degrees.

Does anyone know if I can set VB to work in degrees or how to change the radians to degrees at somepoint in the equation.

The only code that I found that works, somewhat, is to multply the angle by PI/180 which give very close results to the sin(angle).

Quote:

"Adding manpower to a late software project makes it later" - Brooks's Law

Hello there,
i am getting a coded GPS fix from a remote device of 3f64c80f which my application converts to decimal 1063569423.this decimal apparently relates to 0.893678 radians. does anyone have any idea of how these 2 numbers may relate?ANY help offered gratefully received we are 3 days in and none the wiser!

I'm currently designing a program to do some calculations including the tangent, sine and cosine. My problem is that the corresponding functions give an output in radials and I want it in degrees. How do I convert, and if that is not possible, how do I write my own function for calculating the tangent, sine and cosine?

------------------
Doomstar
http://come.to/Doomstar

Converting +/- 180 Degrees Format Into +/- 90 Format
I'm pretty bad at math, however I need to answer a math problem.

Here's the situation:

There's a circle. It's setup like this:

180
-90 90
0

(edit: having a bit of formatting issues here, with spaces, but you get the idea)

How can I convert that degree-format into a +/- 90 degree format?

Example:

-150 would be -30 degrees (+150 would be 30)
-120 would be -60 degrees (+120 would be 60)

I would need the code to take the -150 number, and output -30. If the input was 150, the output would need to be 30. Obviously not just those numbers, it would be for every degree.

Is this doable? I can't get the logic behind doing such a thing, really wish my math was better. :/

Edited by - ThisIsMyUserName on 3/17/2006 1:05:32 PM

What Should I Store My Angles(radians) As?
what should i store my angles(radians) as?
singles,doubles,longs

How Many Degrees?
Creating a GPS simulator.
Having drawn a line on a chart, I have the coordinates (X1, Y1 to X2, Y2). How do I determine the lines direction as degrees of a compass (0 to 360 degrees)?

I am new to this type of programing, so the simpler the answer, the better.

Many thans for any help.

Morton

Sin Cos Tan In Degrees?
The standard Sin Cos Tan functions return their answers in radiens is there a function which returns it in degree or do I have to just convert it (which is simple enough but its more tidy if there is a dedicated function)

Getting VB To Think In Degrees?
From the looks of this program, VB is thinking in radians.. .and I can't have that... because the purpose of this program is to roughly calculate pi... Is there any way to force VB to think in degrees without any conversion number?

Degrees Problem
im converting coordinates but i cant get the answers to work with negitive coordinates. These are the resulta i am getting buti want my results to use the full 360 degrees.

These are the results that i am getting

x=1 y=1

t=45 r = 1.4142135623731

which is correct

x=1 y =-1

t=-45 r=1.4142135623731

this is wrong t should = 135

x=-1 y=-1

t=45 r=1.4142135623731

this is wrong t should = 225

x=-1 y=1

t=-45 r=1.4142135623731

again r is right but t is wrond should be 315

any suggestions?

Rotating A Picture 28 Degrees(!)
hi everyone,

does anyone know a way to rotate a picture? but not 90 degrees or 180 degrees. my program scans a picture (which is also scanned by a scanner), however the paper generally does not fit perfectly, so i may have to rotate it, like the one in paint shop pro or photoshop.

Inverse Tangent In Degrees
For all you math junkies...

I'm trying to find the inverse tangent of ( ry1 / rx1) in degrees.
First i tried:

direction = Atn((ry1 / rx1) * Math.PI / 180)

No good.
Next:

direction = Atn((ry1 * Math.PI / 180) / (rx1 * Math.PI / 180))

No good either. Sorry for such a dmb question. I haven't had physics yet and i cant figure this out.

does anyone know how to change the default in vb when doing trigonometry from radians to degrees/know how to convert between the two?

360 Degrees Turning Of An Picture
I want to make an anlogue clock with instead of a line as a second hand, a picture, is this possible?

Corwin

Why Is My Rotation 180 Degrees Out Of Phase? GDI+?
When I tried running your pjt.vbp in the RotateSave.zip I get "Varible not defined" for the line:

Public Function CreateFont(ByVal oFont As StdFont, Optional ByVal eFontStyle As FontStyle = FontStyleRegular, Optional ByVal eUnit As Unit = UnitPoint) As Long

and the variable, FontStyleRegular

This puzzles me since I got the thing running a few months ago. I wanted to try it again so I got a new download and now it won't run.

Help??

Why Is My Rotation 180 Degrees Out Of Phase? GDI+?
"Here's a clone example I did for saving rotated GDI+ images: http://www.xtremevbtalk.com/attachm...achmentid=18223"
and downloaded the code. It executes with my VB6 but nothing in the picture shows any rotation? Just a stationary "VB".
Is there some other code that I need to run your example?
George Losey

Why Is My Rotation 180 Degrees Out Of Phase? GDI+?
Sir (Mr. onErr...),
Could you help me with a quick explanation of the 4 calls you make to your graphics class to rotate an image. I'm referring to:

graphics.RotateTransform sngAngle
graphics.TranslateTransform IMG_SIZ 2, IMG_SIZ 2, MatrixOrderAppend
graphics.DrawImageRectI bitmap.Handle, IMG_SIZ 2, IMG_SIZ 2, -IMG_SIZ, -IMG_SIZ
graphics.ResetTransform

It took me a couple of tries to see it happening because my image is a little complex but when I enter a rotation of 10 (sngAngle = 10!) degrees it spins the picture 190 degrees. (sigh) I figured out that you are using the IMG_SIZ 2 to indicate the center of the picture and that your image is square but I must confess to being confused by the procedure names and the enum MatrixOrderAppend. ?? I also tried a negative angle as input and while it didn't crash anything it again gave me unexpected results.

My supposition is that these procedures view my image data from another origin than is determined by the standard picturebox but I'd like confirmation before I proceed further and maybe a hint how to get around that if true.

I would greatly appreciate a brief description of what these are doing so that I can use them correctly.

Animal.

**RESOLVED*** Degrees In VB -- Thanks To JCIS!
I have the following code that I tried to display the line angle in degrees, but it just seem so display it differently than how I normally know, i.e., 0 is on the left, 90 is at the north, 180 is at the west and 270 is at the south.

My line is supposed to be about 41 or so degrees but it keeps showing as 131 degrees.

Here is the vb code:

Code:
Private Sub Command1_Click()
Dim slope As Single
'slope = radtoded(Abs((Line1.X2 - Line1.X1) / (Line1.Y2 - Line1.Y1)))
slope = radToDeg(Abs((4320 - 1560) / (1080 - 2280)))
MsgBox slope
End Sub

Dim PI As Single
PI = 3.1415
End Function

Rotating An Image 90 Degrees
Can anyone tell me if its possible to take a 10x100 image and rotate it 90 degrees so its now 100x10 using bitblt?

Im starting to thing i am going to have to do it pixel by pixel if not. The size is just an example, i want to be able to do it with images of over 3000x2000 for example so speed is a big point
Cheerz

Getting The Degrees Symbol In A Label
hi all
i would like to insert the special character for degrees does anybody know how this is done
g.g

Help Identifying Figures W.degrees
i am a v.new vb user.
i need code that will will let me identify if a figure in a cell is less or more than 17.00°C. all figures are followed by °C... can this be done?

How Do I Rotate A Text Box 90 Degrees In Vba
Hello Friends,

I am using VBA in excel 2000. How do I rotate a text box so that it is vertical and not horizontal.

So if I type in Visual it would show up as

V
I
S
U
A
L

as opposed to VISUAL

Thanks,

Rajesh

Flip An Image 90 Degrees.
Hi,

Does anyone know how I can flip the picture 90 degrees. I know I can use two pictureboxes, but I don't want to use two of them. I only use one picturebox to flip images.

------------------
It is by will alone I set my mind in motion.

Kain_Emanon@mailcity.com

Rotate A Label 90 Degrees
I would like to turn a label 90 degrees or any other amount. Fo instance, if I want to make a map and show the street names i different directions. I am working in .net. I looked at all th properties for a label and couldn't find one that works. It i probably some simple piece of code that turns the text. Thank for your help.

How To Rotate An Object 90 Degrees
Hello, I am still really new to VB, I was wondering how I can rotate an object, like a button or picture or control thing, 90 degrees when clicked, and back when clicked again.

Thanks!

Is It Possible To Flip A VB Form By 90 Degrees
Hello all, I was wondering if anyone knows if it is possible to flip a VB form through 90 degrees when requested by some event. As always any help given is much appreciated. Thanks people

Word Tables At 90 Degrees?
Anyone ever written a function to transpose a table with the objective of rotating the table to 90' ?

Rotate A Label 90 Degrees.
I want a label on my main form but I want the text to be rotated 90 degrees.
How do I do that?

Rotating Form's Text (by 90 Degrees CCW)
I would like to rotate text on a form by 90 degrees Counter Clock Wise).
1. Is there a way to place a text directly on a form (ie – not using label or text box)?
2. Is there a way to rotate the text?
3. is there a way to place a rotated label on a form and then place text in the label that will appear tilted (rotated)?
Perhaps there is a third party Add-In / components that I can use?

Finding Degrees From Centre 0,0 Of Mouse
ok ive made the center of my screen (0,0)
Ive got the MouseX and MouseY

I want to find the angle of the mousepoint(MouseX,MouseY) to the (0,0)

ive already done this but has a few annoying errors..so i was wonderin if u could do it for me

How To Rotate A Textbox/label 90 Degrees Pls Help
pls help i would like to learn how to rotate a textbox or label 90 degree coz i making a program , it is to print a page and i am using form1.printform but it does not print the lower part of the page and so i am force to turn it 90 degree o it can be printed out . now the problem is taht i need to turn all the textbox/label 90 degrees too >.< pls help!!!!!!!!!!!!

Mathematical Problem: Degrees In A Circle
Hi there!

Darn, i'm stuck on this mathematical problem.

I want to make a function witch inputs an X and Y point and output the degrees(0/360 = North 180 = South 90 = East 270 = West) compared to the world origin (0,0). So if the input is 25,25 the output would be 45 as in 45 degrees.

My friend told me the name of some ancient algoritm or formula for this but of course i forgot the name of it.

Any help is apprichiated, tnx!

How To Draw Line Under Angle 45 Degrees And Not Only
Hi

How to draw line clicking on Command1 but under angle 45, 135, 225 and 315 degrees.

e.g. I have 1 Command, 2 TextBoxes. Into text1 i wrote direction (in degrees) and into Text2 i wrote length for line (will be better in centimetres), then only I Click on Command1 and...it is already my line
Only is a little problem - I don't know, how to make.

So, how can I do this??? everyone help is useful, thanks in advance.

Convert A Rotation Matrix To Degrees?
I have a 4x4 rotation matrix.

4 floats.

Can I calculate these 4 matrix/vectors into a 360-degree system?
And the other way around?

help would be much appreciated.

Six Degrees Of Kevin Bacon *Resovled*
Does anyone know the logic i would want to use if i was going to make a program very similar to the Six Degrees of Kevin Bacon. I want to do it with kids from my school. I would have 2 list boxes where you would choose who to start with and who to end with. And then figures the connection to people and trys to do it in 6 steps or less. I figure that i would need a file that holds every persons name and who that person is connected to. And even if i did that how could the computer be able to search throguh and finds it way to the corect ending person quickly and effieciently.

Printing A Page 90 Degrees Left
Can anyone help me please, I have a problem:

I have a listview with al kind of information and I want to print that, but there is a problem. The width of an A4 page is to small for that.
Now I want to turn my page 90 degrees.

How do I print that?????????

thanks a lot

Arc Sine, Arc Cosine, Arc Tangent, In Degrees
Anyone know how to get the arc sine arc cosine and arc tangent in degrees? The atn function gives out radians, and i'm not sure about the conversion... I have a way to do sine/cosine/tangent in degrees, but i'm not sure how to do it the other way around. anyone have any idea?

Rotate Screen Ouput 90 Degrees
Is it possible for VB6 to rotate the screen output 90 degrees?
Example, if I wanted to turn my monitor on its side, can VB6 turn the screen back to a position you can easily see?
I know this sounds ridiculus, but it is a real question.

Property On A DataGrid To Turn It 90 Degrees?
Is anyone aware of a datagrid product that would allow me to show table attributes/fields as rows the data as columns? In essence all I would like to do is turn a datagrid 90 degrees. Preferably the product would work with ADO/Access.

Thanks!

Word VBA Print - Rotate 180 Degrees
I'm trying to do something rather odd for a Word template.

I have used the code from KB article 230743 and managed to bodge it and print duplex using VBA code.

Unfortunately, I need to print duplex onto headed paper. My printer prints duplex pages upside down and back to front, which doesn't matter when you're printing on plain, but a bit awkward for headed.

Obviously could flip paper in printer, but then anything that isn't duplex will be upside down and back to front.

My printer has an option to print rotated 180 degrees, and the doc is only 2 pages, so I can get it to print backwards and all is well.

Does anyone know how to tell my printer to print rotated 180 degrees in code? I'm assuming there's some kind of similar property setting that I can change like with the duplex printing?

My printer is an HP 4200 dtn.

Any help or suggestions very welcome, getting quite desperate and confused!

Rotate Print 90 Degrees Within A Page
I am trying to print a page with 4 lines landscaped, and one line portrait. I know you can not change the orientation mid page, so is there any property to use to rotate one line. In DOS, you could send commands to the print, but in trying this in VB just prints the literal command. Here is the code I am currently using for the landscaped lines, I need to print the employee number vertically on the left side of the page. Thanks in advance for any help.

Catrina

With MyFont
.Bold = true
.Name = "courier new"
End With
set Printer.Font = MyFont
Printer.FontSize = 12
Printer.Orientation = vbPRORLandscape

If StopPrint\$ = "Y" then End
SavEmp& = Val(rsMast!PayEmp)
Printer.CurrentY = 10130
Printer.print " " & RTrim(rsMast!LName); ", "; rsMast!FstName;

Printer.CurrentY = 10450
Printer.print " Emp No " & Right(" " & CStr(Val(rsMast!PayEmp)), 6);

If SavEmp& &lt;&gt; Val(rsMast!PayEmp) then
BEEP
BEEP
Label3(0).Caption = "Emp#" + CStr(SavEmp&) + _
" printed as emp# " + rsMast!PayEmp
Label3(1).Caption = "**PLEASE CHECK time SHEET** -Press any key to continue-"
Do While StopPrint\$ = ""
DoEvents
Loop
End If
Printer.CurrentY = 10720
Printer.print " Div " & Right(" " & rsMast!cdiv, 4) & " Dept " & _
Right(" " & rsMast!cdEPT, 4);
Printer.CurrentY = 10990
Printer.print " Week Ending " + Zout\$;
Printer.EndDoc

Text Box Format Degrees Minutes Seconds 0°.00' 00''
Hi, I am just trying to format a form text box, using VB6 to show degrees minutes seconds.

The standard we generally use is to enter the number as
123.4512 then when the focus is changed to another field it would be displayed like this: 123°.45' 12''
or the decimal point could be dropped 123° 45' 12''

The number needs to be saved in the format 123.4512 for use in calculations though.

All of the examples I have found relate to currency and controlling numbers only entry. Any help would be greatly appreciated.

Common Dialog Rotate Printing 180 Degrees
Hi,

I have a Samsung ML-2510 printer. When the printer common dialog comes up to print and I select Properties, the properties form has an option in the Paper Orientation to select a 180 degree rotation. How i select this programmatically?

Thanks,
John