如何把字符串中的所有反正弦函数都转换成反正切函数(要代码)
示例:
asin(0.5)*asin(asin(0.4)*2)*atn(asin(0.1))+sin(20+asin(0.2))
asin()反正弦函
atn()反正切函数
示例:
asin(0.5)*asin(asin(0.4)*2)*atn(asin(0.1))+sin(20+asin(0.2))
asin()反正弦函
atn()反正切函数
调试欢乐多
s = "asin (0.5) * asin(asin(0.4) * 2) * Atn(asin(0.1)) + Sin(20 + asin(0.2))"
s = Replace(s, "asin", "atn")
MsgBox s
End Sub
Dim s As String
s = "asin(0.5) * asin(asin(0.4) * 2) * Atn(asin(0.1)) + Sin(20 + asin(0.2))" Dim i As Long
s = Replace(s, " ", "")
Debug.Print s
Dim j As Long
Dim count As Long
Dim c As String
Dim l As Long
Dim e As Long
Do
i = InStr(1, s, "asin(")
If i > 0 Then
count = 1
l = Len(s)
e = 0
For j = i + 5 To l
c = Mid(s, j, 1)
If c = "(" Then
count = count + 1
End If
If c = ")" Then
count = count - 1
End If
If count = 0 Then
e = j
Exit For
End If
Next j
If e <> 0 Then
c = Mid(s, i + 5, e - (i + 5))
c = c & "/(1-" & c & "^2)^" & c
Debug.Print c
s = Mid(s, 1, i - 1) & "atan(" & c & ")" & Mid(s, e + 1)
End If
End If
Loop While i
Debug.Print s
End Sub
Dim s As String
s = "asin(0.5) * asin(asin(0.4) * 2) * Atn(asin(0.1)) + Sin(20 + asin(0.2))" Dim i As Long
s = Replace(s, " ", "")
Debug.Print s
Dim j As Long
Dim count As Long
Dim c As String
Dim l As Long
Dim e As Long
Do
i = InStr(1, s, "asin(")
If i > 0 Then
count = 1
l = Len(s)
e = 0
For j = i + 5 To l
c = Mid(s, j, 1)
If c = "(" Then
count = count + 1
End If
If c = ")" Then
count = count - 1
End If
If count = 0 Then
e = j
Exit For
End If
Next j
If e <> 0 Then
c = Mid(s, i + 5, e - (i + 5))
c = c & "/(1-" & "(" & c & ")^2)^" & 0.5 Debug.Print c
s = Mid(s, 1, i - 1) & "atan(" & c & ")" & Mid(s, e + 1)
End If
End If
Loop While i
Debug.Print s
End Sub