관리 메뉴

Today is Present.

에듀파인 예산입력자료에서 산출식 문자열 계산 모듈(CalStr) 본문

신속한 업무를 위한 팁

에듀파인 예산입력자료에서 산출식 문자열 계산 모듈(CalStr)

MorningPhys 2020. 11. 24. 11:41

에듀파인 예산입력자료 엑셀에서 활용된 모듈입니다.

해당 모듈은 셀에서 텍스트와 같이 입력된 값에서 숫자만 가지고와 산술계산을 하는 모듈입니다. 

 

ex)

산출식에 72,000원*2명*3일= 이라고 기재되어 있는 text 를 연산부호에 따라 계산하여

요구금액(432,000)을 산출하는 사용자 정의함수

 

CalStr 모듈

Function CalStr(strS As String)

Dim i As Integer
Dim Tmp_Text, strText As String

On Error Resume Next
Tmp_Text = ""
For i = 1 To Len(strS) + 1
     strText = Mid(strS, i, 1)

     If (strText Like "[0-9]" Or strText Like "[+*/.%)(-]") Then
        Tmp_Text = Tmp_Text & strText
     End If
Next i
    
If Tmp_Text = "" Then
     CalStr = 0
Else
     CalStr = Evaluate(Tmp_Text)  
     If CalStr Mod 1000 > 0 Then
         CalStr = ((CalStr \ 1000) + 1) * 1000
     End If
End If

End Function

Function CalMinus(thisY As Double, lastY As Double)
    CalMinus = thisY - lastY
End Function

728x90
반응형