VB编程题大家帮帮忙

2024-11-30 18:18:38
推荐回答(2个)
回答1:

1、
Private Sub Form_Click()
Dim x%, y!
x = Val(InputBox("请输入x的值"))
Select Case x
Case 0: y = Cos(x) - x ^ 3 + 2 * x
Case Is <> 0: y = Sin(x) + Sqr(x ^ 2 + 1)
End Select
MsgBox "y=" & y
End Sub
2、
Private Sub Form_Click()
Dim i%, s%, n%
For i = 1 To 100
If i Mod 3 = 0 Then: n = n + 1: s = s + i
Next
MsgBox "1~100之间能被3整除的数有" & n & "个,它们的和是:" & s
End Sub
3、
Private Sub Form_Click()
Dim h%, f%, x%, y%
h = Val(InputBox("请输入鸡和兔的总头数h", , "71"))
f = Val(InputBox("请输入鸡和兔的总脚数f", , "158"))
y = (f - h * 2) / 2 '兔子
x = h - y '鸡
Print "笼中有"; x; "只鸡,"; y; "只兔"
End Sub
4、
Private Sub Form_Click()
Dim i%, j%, s%
j = 1
For i = 1 To 10
s = s + (i + j * i) / i * (i + 1)
Next
MsgBox "s=" & s
End Sub
6、
Private Sub Form_Click()
Dim i%, j%
For i = 0 To 4
Print Space$(i);
For j = 8 To 2 * i Step -1
Print "*";
Next j
Print
Next i
End Sub

回答2:

第一个我不会,好久没学习了,三角函数都记不清了。看都看不明懂,第二个简单,要我答就选我最佳。第三个我感兴趣,帮你做出来了。第四第五我不会,原因和第一个不会一样。哈哈,看代码吧,谁叫你一下子发出5个问题,都没分加啊```
Private Sub Command1_Click()
h = InputBox("请输入鸡和兔的总头数")
f = InputBox("请输入总脚数")
x = (f - 2 * h) / 2
y = h - x
Print "兔子有" & x & "只 " & "鸡有" & y & "只"
End Sub

第一个也给你搞定了,要是没人回答其它的,就选我为最佳吧,呵呵
Private Sub Command1_Click()
For i = 1 To 10
If i Mod 3 = 0 Then
x = x + 1 '个数
y = i + i
End If
Next i
Print "1到100中有" & x & "个数能被3整除" & vbCrLf & "它们相的结果是" & y

End Sub

补充一下,请问3+3!是什么意思,告诉我,我一并帮你把这个问题给解决掉