我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net度数 vb温度转换代码

在vb中。如何进行三角函数的程序代码编写

有几个地方要注意:

创新互联专注于津南企业网站建设,成都响应式网站建设,商城建设。津南网站建设公司,为津南等地区提供建站服务。全流程按需定制,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

1、VB中的三角函数的角度全部是用弧度制表示的,如果是度数的话,应先乘以180再除以π转成弧度,再用函数计算结果。

2、VB中直接支持的三角函数有:Sin()、Cos()、Tan(),如果涉及到其它三角函数,可以从下面列出的代码中自己选择相应的函数:

Function

Sec(X)

As

Double

'正割

Sec

=

1

/

Cos(Angle)

End

Function

Function

Csc(X)

As

Double

'余割

Csc

=

1

/

Sin(Angle)

End

Function

Function

Cot(X)

As

Double

'余切

Cot

=

1

/

Tan(Angle)

End

Function

Function

ArcSin(X)

As

Double

'反正弦

ArcSin

=

Atn(X

/

Sqr(-X

*

X

+

1))

End

Function

Function

ArcCos(X)

As

Double

'反余弦

ArcCos

=

Atn(-X

/

Sqr(-X

*

X

+

1))

+

2

*

Atn(1)

End

Function

Function

ArcSec(X)

As

Double

'反正割

ArcSec

=

Atn(X

/

Sqr(X

*

X

-

1))

+

Sgn((X)

-

1)

*

(2

*

Atn(1))

End

Function

Function

ArcCsc(X)

As

Double

'反余割

ArcCsc

=

Atn(X

/

Sqr(X

*

X

-

1))

+

(Sgn(X)

-

1)

*

(2

*

Atn(1))

End

Function

Function

ArcCot(X)

As

Double

'反余切

ArcCot

=

Atn(X)

+

2

*

Atn(1)

End

Function

Function

HSin(X)

As

Double

'双曲正弦

HSin

=

(Exp(X)

-

Exp(-X))

/

2

End

Function

Function

HCos(X)

As

Double

'双曲余弦

HCos

=

(Exp(X)

+

Exp(-X))

/

2

End

Function

Function

HTan(X)

As

Double

'双曲正切

HTan

=

(Exp(X)

-

Exp(-X))

/

(Exp(X)

+

Exp(-X))

End

Function

Function

HSec(X)

As

Double

'双曲正割

HSec

=

2

/

(Exp(X)

+

Exp(-X))

End

Function

Function

HCsc(X)

As

Double

'双曲余割

HCsc

=

2

/

(Exp(X)

-

Exp(-X))

End

Function

Function

HCot(X)

As

Double

'双曲余切

HCot

=

(Exp(X)

+

Exp(-X))

/

(Exp(X)

-

Exp(-X))

End

Function

Function

HArcsin(X)

As

Double

'反双曲正弦

HArcsin

=

Log(X

+

Sqr(X

*

X

+

1))

End

Function

Function

HArccos(X)

As

Double

'反双曲余弦

HArccos

=

Log(X

+

Sqr(X

*

X

-

1))

End

Function

Function

HArctan(X)

As

Double

'反双曲正切

HArctan

=

Log((1

+

X)

/

(1

-

X))

/

2

End

Function

Function

HArcsec(X)

As

Double

'反双曲正割

HArcsec

=

Log((Sqr(-X

*

X

+

1)

+

1)

/

X)

End

Function

Function

HArccsc(X)

As

Double

'反双曲余割

HArccsc

=

Log((Sgn(X)

*

Sqr(X

*

X

+

1)

+

1)

/

X)

End

Function

Function

HArccot(X)

As

Double

'反双曲余切

HArccot

=

Log((X

+

1)

/

(X

-

1))

/

2

End

Function

平面坐标二维定位vb 或vb.net

窗体上放一个textbox 两条line 一个label 代码粘贴 运行 即见效果

'*************************************************************************

'**工程名称:平面座标

'**说 明:小鸟工作室 版权所有2007 - 2008(C)1

'**创 建 人:秋色烽火

'**日 期:2007-12-18 14:08:15

'**版 本:V1.0.0

'*************************************************************************

Const DPITCH = 300 '点距

Dim WithEvents oControlx1 As Line

Dim WithEvents oControlx2 As Line

Dim WithEvents oControly1 As Line

Dim WithEvents oControly2 As Line

Dim WithEvents oControlShape As Shape

Dim WithEvents oControlPixinfo As Label

Dim DPCound%, PixID%, PixBackColor, dotx%, doty%

Private Sub Form_Load()

Me.Caption = "平面座标 - by 秋色烽火[小鸟工作室]"

Me.Height = 9300

Me.Width = 9300

Line1.X1 = 150

Line1.X2 = Me.Width - 150

Line1.Y1 = Me.Height / 2

Line1.Y2 = Line1.Y1

Line2.Y1 = 150

Line2.Y2 = Me.Height - 150

Line2.X1 = Me.Width / 2

Line2.X2 = Line2.X1

Label1.Width = 255

Label1.Height = 255

Label1.AutoSize = ture

Label1.BackStyle = 0

Label1.FontItalic = True

Label1.FontBold = True

Label1.FontSize = 10

Label1.ForeColor = HFF

Label1.Caption = "O"

Label1.Left = Me.Width / 2 + Label1.Width - 100

Label1.Top = Me.Height / 2 - Label1.Height

Text1.Text = ""

Call AddLine

Text1.ToolTipText = "请输入整数座标(x,y) 中间用英文逗号分隔~~~,双击文本框或回车开始标注" vbCrLf " 右击显示帮助信息 " vbCrLf "输入座标请介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之间~~"

PixID = 0

End Sub

Sub AddLine()

DPCound = (Me.Width - 300) / DPITCH - 2

For i = DPCound \ 2 + 1 To DPCound

Set oControlx1 = Controls.Add("VB.Line", "lineW" i, Me)

Set oControlx2 = Controls.Add("VB.Line", "lineW" DPCound \ 2 - (i - (DPCound \ 2 + 1)), Me)

Set oControly1 = Controls.Add("VB.Line", "lineH" i, Me)

Set oControly2 = Controls.Add("VB.Line", "lineH" DPCound \ 2 - (i - (DPCound \ 2 + 1)), Me)

With oControlx1

.Visible = True '显示

.X1 = Me.Width / 2 + (i - DPCound \ 2) * DPITCH

.X2 = Me.Width / 2 + (i - DPCound \ 2) * DPITCH

.Y1 = Me.Height / 2 - 60

.Y2 = Me.Height / 2 + 60

End With

With oControlx2

.Visible = True '显示

.X1 = Me.Width / 2 - (i - DPCound \ 2) * DPITCH

.X2 = Me.Width / 2 - (i - DPCound \ 2) * DPITCH

.Y1 = Me.Height / 2 - 60

.Y2 = Me.Height / 2 + 60

End With

With oControly1

.Visible = True '显示

.Y1 = Me.Height / 2 + (i - DPCound \ 2) * DPITCH

.Y2 = Me.Height / 2 + (i - DPCound \ 2) * DPITCH

.X1 = Me.Width / 2 - 60

.X2 = Me.Width / 2 + 60

End With

With oControly2

.Visible = True '显示

.Y1 = Me.Height / 2 - (i - DPCound \ 2) * DPITCH

.Y2 = Me.Height / 2 - (i - DPCound \ 2) * DPITCH

.X1 = Me.Width / 2 - 60

.X2 = Me.Width / 2 + 60

End With

Next

End Sub

Sub AddPix()

If InStr(Text1.Text, ",") 0 Then

If IsNumeric(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) And IsNumeric(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text))) Then

If CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) = DPCound \ 2 And CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) = -1 * DPCound \ 2 Then

PixID = PixID + 1

Set oControlShape = Controls.Add("VB.Shape", "Pix" PixID, Me)

Set oControlPixinfo = Controls.Add("VB.Label", "Pixinfo" PixID, Me)

With oControlShape

.Visible = True '显示

.Shape = 3

'.BorderColor = HFF

.BackColor = HFF 'RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255)) 'HFF

.BackStyle = 1

.BorderStyle = 0

.Width = 75

.Height = 75

.Left = Me.Width / 2 + CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1)) * DPITCH

.Top = Me.Height / 2 - CInt(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text))) * DPITCH

dotx = .Left

doty = .Top

PixBackColor = .BackColor

End With

With oControlPixinfo

.Visible = True '显示

.BackStyle = 0

' .FontItalic = True

'.FontBold = True

.FontSize = 9

.ForeColor = HFF 'PixBackColor 'HFF

.Caption = "[" PixID "]" CStr(CInt(Mid$(Text1.Text, 1, InStr(Text1.Text, ",") - 1))) "," CInt(Mid$(Text1.Text, InStr(Text1.Text, ",") + 1, Len(Text1.Text)))

.Width = 1000

.Height = 255

.Left = dotx

.Top = doty - .Height

.AutoSize = ture

End With

Text1.Text = ""

Else

MsgBox "输入座标请介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之间~~", , "错误"

Text1.Text = ""

End If

Else

MsgBox "座标请使用数字输入", , "错误"

Text1.Text = ""

End If

Else

MsgBox "输入的座标请使用英文逗号 , 进行分隔", , "错误"

Text1.Text = ""

End If

End Sub

Sub init()

If PixID 0 Then

If MsgBox("确实要清空所有标注点吗?", vbOKCancel + vbInformation + vbDefaultButton2 + vbMsgBoxSetForeground + vbSystemModal, "信息!") = vbOK Then

For i = 1 To PixID

Controls.Remove "Pix" i

Controls.Remove "Pixinfo" i

Next

PixID = 0

End If

End If

End Sub

Private Sub Text1_DblClick()

Call AddPix

End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 13 Then

Call AddPix

End If

End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 2 Then

MsgBox "请输入整数座标(x,y) 中间用英文逗号分隔~~~,双击文本框或回车开始标注" vbCrLf "输入座标请介乎于" DPCound \ 2 "至" -1 * DPCound \ 2 "之间~~" vbCrLf "中键清空所有创建的座标", , "帮助"

End If

If Button = 4 Then

Call init

End If

End Sub

'好玩的东东

'****************************

'如果加上下面的就好罗

'定时设为500

'Dim a, b As Integer

'a = 14

'b = 14

'Private Sub Timer1_Timer()

'Text1.Text = a "," b

'a = a - 1

'b = b - 1

'Call Text1_KeyDown(13, 1)

'End Sub

VB中有没有处理"角度计算"的函数?

没有啊

因为在 VB 里面都使用弧度(RAD)来计算 sin,cos,tan 等的值

而你要进行角度(DEG)计算

因此可以自己动手(丰衣足食)

如果先将你给的度数转化一下单位,就能简单一些

首先,需要声明函数(VB 6.0)

'==============================

'将度(DEG)转化为秒(DEG)

'返回值:与输入的度、分、秒等价的秒数

'==============================

Function DegreeToSecond(ByVal Degree, Optional ByVal Minute, Optional ByVal Second)

DegreeToSecond = (Degree * 60 + Minute) * 60 + Second

End Function

'==============================

'将秒(DEG)转化为度(DEG)

'返回值:与输入的秒数等价的度、分、秒

'注意:此函数返回一个数组,有三个元素组成

' 例如:

' 若 RV = SecondToDegree(12.345)

' 则 RV(0) 为度数

' 则 RV(1) 为分

' 则 RV(2) 为秒

'==============================

Function SecondToDegree(ByVal Second) As Variant()

Dim ReturnValue() As Variant

ReDim ReturnValue(2)

ReturnValue(0) = Fix(Second / 3600)

ReturnValue(1) = Fix((Second - Degree * 3600) / 60)

ReturnValue(2) = Fix((Second - Degree * 3600) - Minute * 60)

SecondToDegree = ReturnValue

End Function

然后,进行操作,例如:

Dim RV() As Variant

RV = SecondToDegree(DegreeToSecond(45, 23, 56) + DegreeToSecond(67, 45, 12))

MsgBox "Result:" RV(0) "°" RV(1) "'" RV(2) """"

如果是在 VB.NET 中,把所有的 Variant 参数和没有带类型的参数(在 VB6 中默认为 Variant)声明为 Object 类型即可


本文标题:vb.net度数 vb温度转换代码
URL地址:http://mswzjz.cn/article/doppidj.html

其他资讯