vb求m+mm+mmm+...+mm...mmm(n个m)要求 n ,m值 用 inputbox输入Dim m%,n%,i%,j%,a(0 To 9999999) As IntegerPrivate Sub Form_Click()m = InputBox("请输入m值 ")n = InputBox("请输入n值 ")For i = n To 0 Step -1a(n) = a(n) + 10 ^ (i - 1)Next iPrint SUM(m,n)End SubPrivate Function SUM(m As Integer,n As Integer) As LongIf n = 1 ThenSUM = mElseSUM = m * a(n) + SUM(m,(n - 1))End IfEnd Function帮忙把这个改一改
问题描述:
vb求m+mm+mmm+...+mm...mmm(n个m)
要求 n ,m值 用 inputbox输入
Dim m%,n%,i%,j%,a(0 To 9999999) As Integer
Private Sub Form_Click()
m = InputBox("请输入m值 ")
n = InputBox("请输入n值 ")
For i = n To 0 Step -1
a(n) = a(n) + 10 ^ (i - 1)
Next i
Print SUM(m,n)
End Sub
Private Function SUM(m As Integer,n As Integer) As Long
If n = 1 Then
SUM = m
Else
SUM = m * a(n) + SUM(m,(n - 1))
End If
End Function
帮忙把这个改一改
答
Private Sub Command1_Click()
Dim i As Integer,n As Integer,m As Integer,Str As String,S As Double
Str = ""
n = Val(InputBox("N"))
m = Val(InputBox("M"))
For i = 0 To n
S = S + Val(Str)
Str = Str & m
Next i
Print S
End Sub