论坛有位朋友congcong99想要,我就写出来了..现在发出来,,希望大家可以学习一下..
''''''''''''''''''''''''''''''''''''''''''''''''
'-------------程序员:purana--------------------
'-------------编写时间:2006,10,12--------------
'-------------邮箱: myfend_liang@yahoo.com.cn--
'-------------功能:精确计算30位以上的数的和----
'''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Private Sub Command1_Click()
Dim Num1 As String, Num2 As String
Dim L1 As Integer, L2 As Integer
Dim L As Integer, n As Integer
Dim a As Integer, b As Integer, c As Integer
Dim i As Integer
Dim DestString As String
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "请输入一个数"
Exit Sub
End If
If Not IsNumeric(Text1.Text) Or Not IsNumeric(Text2.Text) Then
MsgBox "请输入数字"
Exit Sub
End If
Num1 = Trim(Text1.Text)
Num2 = Trim(Text2.Text)
L1 = Len(Num1)
L2 = Len(Num2)
If (L1 > L2) Then
L = L1
Num2 = String(L1 - L2, "0") & Num2
Else
L = L2
Num1 = String(L2 - L1, "0") & Num1
End If
For i = 1 To L
a = Mid(Num1, L - i + 1, 1)
b = Mid(Num2, L - i + 1, 1)
c = a + b + n
If (c > 9) Then
n = 1
Else
n = 0
End If
DestString = Trim(Str(c)) & DestString
Next
If (n > 0) Then
DestString = Right(Trim(n), 1) & DestString
End If
Text3.Text = DestString
End Sub
Private Sub Command2_Click()
Unload Me
End Sub