do while 语句
编写程序,已知:S=1+3+5+7+...+99,求S不大于150的最大整数值 用do while 语句来做 快考试了这道题还是不会做
--------------------编程问答--------------------
--------------------编程问答--------------------
--------------------编程问答--------------------
Private Sub Command1_Click()
Dim a As Integer, S As Integer
a = 1
Do
S = S + a
a = a + 2
Loop While S + a < 150
MsgBox S
End Sub
--------------------编程问答--------------------
--------------------编程问答--------------------
--------------------编程问答--------------------
Private Sub Command1_Click()
Dim i, s, t As Integer
i = 1
s = 0
Do While s < 150
t = s
s = s + i
i = i + 2
Loop
MsgBox t
End Sub
--------------------编程问答--------------------
Private Sub Form_Load()
Dim s As Integer
Do While s <= 150
temp = s
s = s + 2
Loop
MsgBox "满足条件的s为:" & temp, vbInformation, "结果"
End Sub
补充:VB , 基础类