vb编程 要计算2+22+222+2222……222222n要怎么写?
2013-12-10
展开全部
Private Sub Form_Click()
Dim n As Integer
n = InputBox("请输入一个老兄坦尘键整数:"侍桐)
For i = 1 To n
s = s + Val(String(i, "2"))
Next i
Print s
End Sub
Dim n As Integer
n = InputBox("请输入一个老兄坦尘键整数:"侍桐)
For i = 1 To n
s = s + Val(String(i, "2"))
Next i
Print s
End Sub
2013-12-10
展开全部
Private Sub Form_Click()
Dim i As Integer
Dim d As Integer
Dim n As Integer
Dim num As Long
Dim sum As Long
d = 2 '数基滚字,比如2
n = 5 '搏渣余位数梁段,比如5
For i = 1 To n
num = num * 10 + d
sum = sum + num
Next
Print sum
End Sub
Dim i As Integer
Dim d As Integer
Dim n As Integer
Dim num As Long
Dim sum As Long
d = 2 '数基滚字,比如2
n = 5 '搏渣余位数梁段,比如5
For i = 1 To n
num = num * 10 + d
sum = sum + num
Next
Print sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-10
展开全部
Dim s As Long
Dim k As Long
Dim i As Integer
i = 9
For i = 0 To i - 1
k = 2 * (10 ^ i) + k
s = s + k
Next i
Me.AutoRedraw = True
Print s
这桥世陆敏顷里i不能返碧太大,否则会溢出
Dim k As Long
Dim i As Integer
i = 9
For i = 0 To i - 1
k = 2 * (10 ^ i) + k
s = s + k
Next i
Me.AutoRedraw = True
Print s
这桥世陆敏顷里i不能返碧太大,否则会溢出
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询