1、鸡兔同笼在窗体中插入一个按钮,编写如下程序。Private Sub Command1_Click()Dim h%, f%, x%, y%h = InputBox(请输入总头数h:)f = InputBox(请输入总脚数f:)x = 2 * h - f / 2y = f / 2 - hPrint 鸡的数量:; xPrint 兔的数量是:; yEnd Sub将三个数字进行排序的VB代码:Private Sub Form_Click()Dim a#, b#, c#, x#, y#, z#i: a = InputBox(请输入a) b = InputBox(请输入b) c = InputBox(请输入
2、c)If a = b Or b = c Or a = c ThenPrint 输入数据无法运算,请重新输入GoTo iEnd IfIf a b Then x = b If x c Then y = b z = c Else y = c z = b End IfEnd IfPrint 自大至小排序为:; x, y, zEnd Sub输入一个正的三位数,判断是否是水仙花数的VB代码。Private Sub Form_Click()Dim x%, a%, b%, c%i: x = InputBox(请输入一个三位数)If x = 1000 Then Print 请重新输入一个三位数GoTo iElsea = x Mod 10b = x 10 Mod 10c = x 100 Mod 10 If x = a * a * a + b * b * b + c * c * c Then Print x是水仙花数 Else Print x不是水仙花数 End IfEnd IfEnd Sub