當前位置:編程學習大全網 - 網站源碼 - 想用C#做壹個類似於excel裏的公式庫以及公式的運算模塊,可以自定義函數,並可以解析公式並運算

想用C#做壹個類似於excel裏的公式庫以及公式的運算模塊,可以自定義函數,並可以解析公式並運算

1.工具--宏-錄制新宏-確定。

2.在宏窗口上“停止錄制”

3.工具-宏-宏,點擊macro1-編輯,進入壹個窗口,把裏面的內容全部刪除,粘貼下面代碼:

Function GetNum(b)

Dim i As Integer

Dim Al As String

For i = 1 To Len(b)

Al = Mid(b, i, 1)

If IsNumeric(Al) Or Al = "." Then

GetNum = GetNum & Al

End If

Next

End Function

選中壹個單元格後,輸入: =getnum(a1)

如果提取不是數字的,就改成:

Function Getstr(b)

Dim i As Integer

Dim Al As String

For i = 1 To Len(b)

Al = Mid(b, i, 1)

If not IsNumeric(Al) Then

Getstr= Getstr & Al

End If

Next

End Function

選中壹個單元格後,輸入: =getstr(a1)

  • 上一篇:PHP代碼保護方法
  • 下一篇:為什麽下載的粵苗沒有疫苗溯源
  • copyright 2024編程學習大全網