当前位置:文库下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > vb编程代码
免费下载此文档侵权投诉

vb编程代码

vb考试简单代码

计算二的 n 次幂

代码 Private Sub Command1_Click() Dim n As Integer, mi As Double Dim i As Integer n = Int(Val(InputBox(""))) mi = 1 For i = 1 To n mi = mi * 2 Next i Print " 2 的"; n; "次幂为:"; mi End Sub

编写程序,随机生成 100 个两位整数,并统计出 其中小于等于 40、 大于 40 小于等于 70 及大于 70 的数据个数。

代码

Private Sub Command1_Click() Dim x As Integer, i As Integer Dim cnt1 As Integer, cnt2 As Integer, cnt3 As Integer cnt1 = 0: cnt2 = 0: cnt3 = 0 Randomize For i = 1 To 100 x = Int(Rnd * 90 + 10) If x <= 40 Then cnt1 = cnt1 + 1 ElseIf x < 70 Then cnt2 = cnt2 + 1 Else cnt3 = cnt3 + 1 End If Next i Print cnt1, cnt2, cnt3 End Sub 编写程序,单击窗体时在窗体上输出如下所 示的图形。 代码 Private Sub Form_Click() Dim i As Integer, begin As Integer begin = 5 For i = 1 To 5 Print Tab(begin); For j = 1 To 2 * i - 1 Print "*"; Next j Print begin = begin - 1 Next i begin = 2 For i = 4 To 1 Step -1 Print Tab(begin); or j = 1 To 2 * i - 1 Print "*"; Next j Print begin = begin + 1 Next i End Sub

vb编程代码

vb编程代码

vb编程代码

第1页

免费下载Word文档免费下载:vb编程代码

(下载1-16页,共16页)

我要评论

返回顶部