長整數相加、減、乘(編號:4134)

這可是包仔寫很久才寫出來的
提出來與大家分享
至於除法嘛...我還沒寫出來
Public Function AddFunction(Value1 As String, Value2 As String) As String '長整數相加
Dim i As Integer
  Dim j As Integer
  Dim Values1(100) As Integer
  Dim Values2(100) As Integer
  Dim OkValues(100) As Integer
  Dim Steps As Integer
  Dim Limit As Integer
  Dim MaxCounts As Integer
  If Len(Value1) >= Len(Value2) Then MaxCounts = Len(Value1) Else MaxCounts = Len(Value2)
  For i = Len(Value1) To 1 Step -1
    Steps = Steps + 1
    Values1(Steps) = Val(Mid(Value1, i, 1))
  Next i
  Steps = 0
  For i = Len(Value2) To 1 Step -1
    Steps = Steps + 1
    Values2(Steps) = Val(Mid(Value2, i, 1))
  Next i
  For i = 1 To MaxCounts
    OkValues(i) = OkValues(i) + Values1(i) + Values2(i)
    If OkValues(i) >= 10 Then
      Limit = MaxCounts + 1
      OkValues(i + 1) = OkValues(i + 1) + 1
      OkValues(i) = OkValues(i) - 10
    Else
      Limit = MaxCounts
    End If
  Next i
  AddFunction = ""
  For i = Limit To 1 Step -1
    AddFunction = AddFunction & Trim(OkValues(i))
  Next i
  If AddFunction = "" Then AddFunction = "0'"
End Function
Public Function DecFunction(Value1 As String, Value2 As String) '長整數相減
Dim i As Integer
  Dim j As Integer
  Dim Values1(100) As Integer
  Dim Values2(100) As Integer
  Dim BigValue As String
  Dim SmallValue As String
  Dim OverZero As Boolean
  Dim OkValues(100) As Integer
  Dim Limit As Integer
  Dim MaxCounts As Integer
  If Len(Value1) > Len(Value2) Then Value2 = String(Len(Value1) - Len(Value2), "0") & Value2
  If Len(Value1) < Len(Value2) Then Value1 = String(Len(Value2) - Len(Value1), "0") & Value1
  For i = 1 To Len(Value1)
    If Mid(Value1, i, 1) > Mid(Value2, i, 1) Then
      BigValue = Value1
      SmallValue = Value2
      OverZero = False
      Exit For
    End If
    If Mid(Value1, i, 1) < Mid(Value2, i, 1) Then
      BigValue = Value2
      SmallValue = Value1
      OverZero = True
      Exit For
    End If
  Next i
  For i = 1 To Len(BigValue)
    Values1(i) = Val(Mid(BigValue, Len(BigValue) - i + 1, 1))
    Values2(i) = Val(Mid(SmallValue, Len(SmallValue) - i + 1, 1))
    OkValues(i) = OkValues(i) + Values1(i) - Values2(i)
    If OkValues(i) < 0 And i < Len(BigValue) Then
      OkValues(i + 1) = OkValues(i + 1) - 1
      OkValues(i) = OkValues(i) + 10
    End If
  Next i
  For i = Len(BigValue) To 1 Step -1
    If OkValues(i) <> 0 Then
      Limit = i
      Exit For
    End If
  Next i
  DecFunction = ""
  For i = 1 To Limit
    DecFunction = Trim(OkValues(i)) & DecFunction
  Next i
  If OverZero = True Then DecFunction = "-" & DecFunction
  If DecFunction = "" Then DecFunction = "0"
End Function

Public Function SubFunction(Value1 As String, Value2 As String) As String '長整數相乘
Dim Code1(100) As Integer
  Dim Code2(100) As Integer
  Dim Code3(201) As Integer
  Dim Steps1 As Integer
  Dim Steps2 As Integer
  Dim Subtotal As Integer
    ii = Len(Value1)
    jj = Len(Value2)
    Steps1 = 0
    For i = ii To 1 Step -1
      Steps1 = Steps1 + 1
      Code1(Steps1) = Val(Mid(Value1, i, 1))
      Steps2 = 0
      For j = jj To 1 Step -1
        Steps2 = Steps2 + 1
        Code2(Steps2) = Val(Mid(Value2, j, 1))
        Code3(Steps1 + Steps2 - 1) = Code3(Steps1 + Steps2 - 1) + (Code1(Steps1) * Code2(Steps2))
        If Code3(Steps1 + Steps2 - 1) >= 10 Then
          u = Code3(Steps1 + Steps2 - 1) \ 10
          Code3(Steps1 + Steps2 - 1) = Code3(Steps1 + Steps2 - 1) - u * 10
          Code3(Steps1 + Steps2) = Code3(Steps1 + Steps2) + u
        End If
      Next j
    Next i
    For a = 1 To ii + jj - 1
      If Code3(a) >= 10 Then
        u = Code3(a) \ 10
        Code3(a + 1) = Code3(a + 1) + u
        Code3(a) = Code3(a) - u * 10
      End If
    Next a
    SubFunction = ""
    If Code3(ii + jj) <> 0 Then t = ii + jj Else t = ii + jj - 1
    For i = t To 1 Step -1
      SubFunction = SubFunction + Trim(Code3(i))
    Next i
    If SubFunction = "" Then SubFunction = "0"
End Function

Public Function DivFunction(Value1 As String, Value2 As String) As String '長整數相加
Dim MaxLen As Integer
  If Len(Value1) >= Len(Value2) Then MaxLen = Len(Value1) Else MaxLen = Len(Value2)
  If DivFunction = "" Then DivFunction = "0"
End Function