编写函数fun,函数的功能是:当x的初值为10,

编写函数fun,函数的功能是:当x的初值为10,
'每年增长率为百分之一,计算多少年以后x的值能达到y,
'并显示所需年数的值(变量名必须为n).
'要求使用Do ...Loop Until语句来实现.
桔子想想 1年前 已收到1个回答 举报

020_341 种子

共回答了15个问题采纳率:93.3% 举报

Private Sub Command1_Click()
Dim x As Single, y As Single
x = 10
y = 1000
MsgBox fun(x, y)
End Sub

Function fun(x As Single, y As Single) As Long
Do
x = x * 1.01
c = c + 1
Loop Until x >= y
fun = c
End Function

1年前

1
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.240 s. - webmaster@yulucn.com