我创建了一个新的工作簿,并创建了一个新的模块"Module_Trigonometry“,并在那里实现了一个函数"KursWinkel”,我用德语命名变量、宏和函数,以避免与编译器本身的变量发生冲突,但是在这里,我遇到了一个非常奇怪的情况,在主菜单中的"VBA“中的"Developer-Tools”中的工作簿中,“KursWinkel”选项是greyen。如果我进入我的一张床单,例如。"Channel“in one Cell "= Kurs”Excel建议我的完整函数以圆括号打开,当我引用包含Sinus值的单元格并关闭支撑时,我的函数是"#Wert“(值)
Function KursWinkel(Sinus As Double) As Double
'To get the angle for the value of the overgiven sinus-value we can only guess and this we do by
'going throug the entire range of Double
Dim s, r As Long
For s = -4940656458412# To 494065645841247#
If (Abs(Sinus) - Abs(s)) > r Then
Exit For
End If
r = Abs(Sinus) - Abs(s)
Next
KursWinkel = r
End Function这个函数有什么问题?
发布于 2022-06-09 07:51:21
我的新功能是从鼻窦取角度
Function SinusWinkel(Sinus As Double) As Double
'To get the angle for the value of the overgiven sinus-value we can only guess and this we do by
'going throug the sume of angle in a triangle, that is 90° or in sin 0,412118485
'the range is consequently -0,412118485 to 0,412118485
'A negative sin can result wether of a location east of Greenwich or a cours east to west.
'This sub is determined to transformed to a function tha returns the angle to the cell.
'therefore it's implemented in an own module to get rid of it when necessary.
Dim i, k, l, d As Double
For i = -0.412118485 To 0.412118485
l = Sin(i)
d = Abs(Sinus) - Abs(l)
If (d) > k Then
Exit For
End If
k = d
Next
SinusWinkel = k
End Function我在一个包含位置的工作表中使用这个函数,它是纬度和经度,纬度的差异是我的鼻窦,但是要导航,我需要角度。
https://stackoverflow.com/questions/72538411
复制相似问题