楼主参考一下:Option Explicit
Private Function AddNum(ByVal N As Double) As Long
Dim sNum As String
Dim S As Long, i As Long
S = 0: sNum = Fix(N)
For i = 1 To Len(sNum)
S = S + Mid$(sNum, i, 1)
Next
AddNum = S
End Function
Private Sub Command1_Click()
Dim A#, B#, C#, D#
Me.Cls
Randomize
A = Fix(1000000000# + 8999999999# * Rnd())
B = Fix(1000000000# + 8999999999# * Rnd())
D = A + B
C = D / 2
Print "原始值 A = " A
Print "原始值 B = " B
Print "平均值 C = " C
Print " 和值 D = " D
Print "C 的整部分之和为:" AddNum(C)
Print "D 的整部分之和为:" AddNum(D)
End Sub