作业帮 > 综合 > 作业

s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)求大神看看这个VB怎么编.

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/26 07:37:57
s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)求大神看看这个VB怎么编.

s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)并设置S上限 例如选中5000时  当S>5000时停止计算  在列表中输出S和N的值
s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)求大神看看这个VB怎么编.
我帮你做!试下下,问一下,在列表中输出是什么意思,具体点,列表框吗?我是用VB6.0不知道行不行?
再问: 额 就是在哪个白框框中输出···我的是VS2008 菜鸟+新手 应付考试 有劳了
再答: Private Sub Command1_Click()
  Dim s As Integer, i As Integer, j As Integer
  s = 1
  For i = 1 To 10000
     For j = 1 To i
        s = s + j
     Next j
     If Option1.Value = True Then
           If s > 1000 Then
              Exit For
           End If
     End If
     If Option2.Value = True Then
           If s > 5000 Then
              Exit For
           End If
     End If
     If Option3.Value = True Then
           If s > 10000 Then
              Exit For
           End If
     End If
  Next i
  List1.AddItem s & Space(3) & i
End Sub你可以参考我的设计自己再修改一下,请采纳哦!!!