- Public Function PLUS(a As String, b As String) As String
- Dim s_result As String
- Dim s_max As String, s_min As String
-
- If Len(a) > Len(b) Then
- s_max = a
- ElseIf Len(a) < Len(b) Then
- s_max = b
- Else
- If CInt(Left$(a, 1)) > CInt(Left$(b, 1)) Then
- s_max = a
- Else
- s_max = b
- End If
- End If
- If s_max = a Then s_min = b Else s_min = a
-
- Dim x As Double
- Dim x_max As Double
- Dim x_min As Double
-
- Dim c_min As Integer
- Dim c_max As Integer
- Dim c_result As Integer
- Dim retenue As Integer
-
- x = 0
- retenue = 0
-
- debutalgo:
- x_max = Len(s_max) - x
- c_max = CInt(Mid$(s_max, x_max, 1))
-
- If Len(s_min) > x Then
- x_min = Len(s_min) - x
- c_min = CInt(Mid$(s_min, x_min, 1))
- Else
- c_min = 0
- End If
-
- c_result = c_min + c_max + retenue
- If c_result > 9 Then retenue = 1: c_result = CStr(c_result - 10) Else retenue = 0
-
- s_result = c_result & s_result
-
- x = x + 1
- If x < Len(s_max) Then GoTo debutalgo
-
- PLUS = IIf(retenue <> 0, retenue, "") & s_result
- End Function
Public Function PLUS(a As String, b As String) As String
Dim s_result As String
Dim s_max As String, s_min As String
If Len(a) > Len(b) Then
s_max = a
ElseIf Len(a) < Len(b) Then
s_max = b
Else
If CInt(Left$(a, 1)) > CInt(Left$(b, 1)) Then
s_max = a
Else
s_max = b
End If
End If
If s_max = a Then s_min = b Else s_min = a
Dim x As Double
Dim x_max As Double
Dim x_min As Double
Dim c_min As Integer
Dim c_max As Integer
Dim c_result As Integer
Dim retenue As Integer
x = 0
retenue = 0
debutalgo:
x_max = Len(s_max) - x
c_max = CInt(Mid$(s_max, x_max, 1))
If Len(s_min) > x Then
x_min = Len(s_min) - x
c_min = CInt(Mid$(s_min, x_min, 1))
Else
c_min = 0
End If
c_result = c_min + c_max + retenue
If c_result > 9 Then retenue = 1: c_result = CStr(c_result - 10) Else retenue = 0
s_result = c_result & s_result
x = x + 1
If x < Len(s_max) Then GoTo debutalgo
PLUS = IIf(retenue <> 0, retenue, "") & s_result
End Function