3个回答
展开全部
private Sub command1_Click()
Dim Feet,Head,Ji,Tu as interger
Input1:
Feet=InputBox("输入脚数",,"")
Head=InputBox("输入头数",,"")
Tu=Feet/2 - Head
Ji=Head - Tu
If (Ji < 0) Or (Tu < 0) then
MsgBox "输入错误"
Goto Input1:
Else
Open App.Path & "\answer.txt" For Append As #1
Print #1, "鸡="; Ji, "兔="; Tu
Close #1
End if
End Sub
先添加一个command1按钮控件,弄完之后保存在程序目录下的answer.txt文件中
如果要健壮性,辨别错误输入就更麻烦了,需要的话我再写
Dim Feet,Head,Ji,Tu as interger
Input1:
Feet=InputBox("输入脚数",,"")
Head=InputBox("输入头数",,"")
Tu=Feet/2 - Head
Ji=Head - Tu
If (Ji < 0) Or (Tu < 0) then
MsgBox "输入错误"
Goto Input1:
Else
Open App.Path & "\answer.txt" For Append As #1
Print #1, "鸡="; Ji, "兔="; Tu
Close #1
End if
End Sub
先添加一个command1按钮控件,弄完之后保存在程序目录下的answer.txt文件中
如果要健壮性,辨别错误输入就更麻烦了,需要的话我再写
展开全部
Private Sub Command1_Click()
Dim h As Integer, f As Integer
h = Val(InputBox("鸡和兔的总头数", "请输入", 0))
f = Val(InputBox("鸡和兔的总脚数(偶数)", "请输入", 0))
x = (4 * h - f) / 2
y = (f - 2 * h) / 2
Label2.Caption = " 设笼中鸡和兔的总头数为" & h & ",总脚数为" & f & "。"
Label3.Caption = " 则笼中鸡有" & x & "只,兔有" & y & "只。"
End Sub
Dim h As Integer, f As Integer
h = Val(InputBox("鸡和兔的总头数", "请输入", 0))
f = Val(InputBox("鸡和兔的总脚数(偶数)", "请输入", 0))
x = (4 * h - f) / 2
y = (f - 2 * h) / 2
Label2.Caption = " 设笼中鸡和兔的总头数为" & h & ",总脚数为" & f & "。"
Label3.Caption = " 则笼中鸡有" & x & "只,兔有" & y & "只。"
End Sub
更多追问追答
追问
Private Sub Command1_Click()这句话哪里来的
追答
添加一个Command按钮,双击他打开代码窗口就有了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub btnProsse_Click()
Dim intHead As Integer
Dim intFeet As Integer
intHead = Int(tbHead.Text)
intFeet = Int(tbFeet.Text)
Dim Ji As Integer
Dim Tu As Integer
Ji = intFeet / 2 - intHead
Tu = intHead - Ji
Open "C:\123.txt" For Append As #1
Print #1, "鸡="; Ji, "兔="; Tu
Close #1
End Sub
Dim intHead As Integer
Dim intFeet As Integer
intHead = Int(tbHead.Text)
intFeet = Int(tbFeet.Text)
Dim Ji As Integer
Dim Tu As Integer
Ji = intFeet / 2 - intHead
Tu = intHead - Ji
Open "C:\123.txt" For Append As #1
Print #1, "鸡="; Ji, "兔="; Tu
Close #1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询