如何把字符串中的所有反正弦函数都转换成反正切函数(要代码)
示例:
asin(0.5)*asin(asin(0.4)*2)*atn(asin(0.1))+sin(20+asin(0.2))
asin()反正弦函
atn()反正切函数

解决方案 »

  1.   

    Private Sub Form_Load()
    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
      

  2.   

    不是这个意思,而是实现数学转换,如:Asin(0.5)转换成Atn(0.5/(1-0.5^2)^0.5)
      

  3.   

    Option ExplicitPrivate Sub Command1_Click()
        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
      

  4.   

    atan(0.5/(1-0.5^2)^0.5)*atan(atan(0.4/(1-0.4^2)^0.4)*2/(1-atan(0.4/(1-0.4^2)^0.4)*2^2)^atan(0.4/(1-0.4^2)^0.4)*2)*Atn(atan(0.1/(1-0.1^2)^0.1))+Sin(20+atan(0.2/(1-0.2^2)^0.2))
      

  5.   

    就是这个意思,辛苦了,谢谢!Option ExplicitPrivate Sub Command1_Click()
        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