求一个VB高手帮我解答下问题,写3个程序,谢谢!

 我来答
匿名用户
2012-12-19
展开全部
Private Sub Command1_Click()
Dim s As Long, k As Long, n As Integer
k = Val(Text1.Text)
s = Val(Text2.Text)
Do Until s > k
n = n + 1
s = s + n
Loop
Text2.Text = n
End Sub

Private Sub Command1_Click()'第(6)题
Cls
Randomize
Dim n As Integer, k As Integer
For i = 1 To 10
a = Int(Rnd * 90 + 10)
k = k + 1
If a Mod 2 = 0 Then
Print a, "***"
n = n + 1
If n = 4 Then Exit For
Else
Print a
End If
Next i
Print "共产生了"; k; "个数"
End Sub

'第(4)题

Private Sub Command1_Click()
Dim s As Integer, i As Integer, j As Integer, n As Integer
For i = 100 To 999
s = 0
For j = 1 To Len(Trim(Str(i)))
s = s + Val(Mid(Trim(Str(i)), j, 1)) ^ 3
Next j
If s = i Then
n = n + 1
Print "第"; n; "个水仙花数是 :"; i
End If
Next i

End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式