Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
813 B
1
Indexable
Never
Private Function Get_number(Numb As String) As Double
Dim i, dcn As String, numbr As Double, Neg As String
dcn = "0"
Neg = "0"
   For i = 1 To Len(Numb)
   If IsNumeric(Mid(Numb, i, 1)) Or Mid(Numb, i, 1) = "." Or Mid(Numb, i, 1) = "-" Or Mid(Numb, i, 1) = "," Then
       If dcn <> "0" Then
          dcn = dcn & 0
       End If
       If Mid(Numb, i, 1) = "." Then
          dcn = "1"
       End If
       If Mid(Numb, i, 1) = "-" Then
          Neg = "1"
       End If
       If Mid(Numb, i, 1) <> "," Then
          numbr = numbr & Mid(Numb, i, 1)
       End If
     End If
   Next
   If dcn > 1 Then
      Get_number = Val(numbr) / Val(dcn)
   Else
      Get_number = Val(numbr)
   End If
   If Neg <> "0" Then
      Get_number = Get_number * -1
   End If
  ' Return
End Function
Leave a Comment