visual basic程序设计教程第四版答案(刘炳文)
VB编程:编写程序,计算 1+2+3+……+100
用for语句编程的【VB源代码】
Private Sub Command1_Click()
For i = 1 To 100
Sum = Sum + i
Next i
Print Sum
End Sub
用while语句编程的【VB源代码】
Private Sub Command1_Click()
Static sum As Integer
i = 1
While i <= 100
sum = sum + i
i = i + 1
Wend
Print sum
End Sub
***************************************************
VB编程:编写程序,计算 2+4+6+8+……+100
用for语句编程的【VB源代码】
Private Sub Command1_Click()
For i = 1 To 100 Step 2
sum = sum + i
Next i
Print sum
End Sub
用while语句编程的【VB源代码】
Private Sub Command1_Click()
Static sum As Integer
i = 1
While i <= 100
sum = sum + i
i = i + 2
Wend
Print sum
End Sub
新世纪计算机基础教育丛书 丛书主编:谭浩强
Visual Basic 程序设计教程 题解与上机指导(第四版) 刘炳文 编著
来源:visual basic程序设计教程第四版答案(刘炳文)
本文链接:http://www.wb98.com/vb1/post/vb_7.1.html
本站文章搜索: