Thím dùng code này[Visual Basic] 纯文本查看 复制代码 Public Function kl(strText As String)
If Right(strText, 1) = " " Then
kl = "0"
Else
strText = Replace(strText, "m2", "")
strText = Replace(strText, "m3", "")
strText = Replace(strText, "M2", "")
strText = Replace(strText, "M3", "")
strText = Replace(strText, ",", ".")
If vitri(" ", strText) < Len(strText) And vitri(" ", strText) > 1 Then
strText = Right(strText, Len(strText) - vitri(" ", strText))
'Else
End If
kl = ""
For i = 1 To Len(strText)
kytu = Mid(strText, i, 1)
If kytu = "0" Or kytu = "1" Or kytu = "2" Or kytu = "3" Or kytu = "4" Or kytu = "5" Or kytu = "6" Or kytu = "7" _
Or kytu = "8" Or kytu = "9" Or kytu = "+" Or kytu = "-" Or kytu = "*" Or kytu = "/" Or kytu = "^" Or kytu = "." _
Or kytu = "," Or kytu = "(" Or kytu = ")" Or kytu = "%" Then
kl = kl & kytu
End If
Next
If kl = "" Then
kl = 0
End If
End If
If IsError(Evaluate(kl)) Then
kl = ""
Else
kl = Round(Evaluate(kl), 3)
If kl = 0 Then
kl = ""
End If
End If
End Function |