哪位能告诉我哪里出错拉 VB初学者
来源:百度知道 编辑:UC知道 时间:2024/09/24 12:15:42
Private Sub Command1_Click(intex As Integer)
Dim a As Single, b As Single, c As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a + b <= c Then
warn.Caption = "无法构成三角形"
typetri.Caption = ""
Else
Dim p As Single
p = (a + b + c) / 2
s.Caption = Sqr(p * (p - a) * (p - b) * (p - c))
l.Caption = a + b + c
anglea = Str((b * b + c * c - a * a) / (2 * b * c))
angleb = Str((a * a + c * c - b * b) / (2 * a * c))
anglec = Str((b * b + a * a - c * c) / (2 * b * a))
If anglea = 0 Or angleb = 0 Or anglec = 0 Then
typetri.captionn = "直角三角形"
ElseIf anglea < 0 Or angleb < 0 Or anglec < 0 Then
typetri.Caption = "钝角三角形”"
Else
typetri.Caption = "锐角三角形"
End If
End If
End Sub
一楼的
captionn是什么啊 我改了没什么用啊
没用啊
有什么不一样吗???
Dim a As Single, b As Single, c As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a + b <= c Then
warn.Caption = "无法构成三角形"
typetri.Caption = ""
Else
Dim p As Single
p = (a + b + c) / 2
s.Caption = Sqr(p * (p - a) * (p - b) * (p - c))
l.Caption = a + b + c
anglea = Str((b * b + c * c - a * a) / (2 * b * c))
angleb = Str((a * a + c * c - b * b) / (2 * a * c))
anglec = Str((b * b + a * a - c * c) / (2 * b * a))
If anglea = 0 Or angleb = 0 Or anglec = 0 Then
typetri.captionn = "直角三角形"
ElseIf anglea < 0 Or angleb < 0 Or anglec < 0 Then
typetri.Caption = "钝角三角形”"
Else
typetri.Caption = "锐角三角形"
End If
End If
End Sub
一楼的
captionn是什么啊 我改了没什么用啊
没用啊
有什么不一样吗???
没人回答呀?那我来吧。
好像只有一处错误,挺明显:
typetri.Captionn = "直角三角形"
改为:typetri.caption = "直角三角形"
补充:
对不起写反了;应该是Captionn 改为 caption
caption 应该是Label的标题
本例中属于Label控件(用来显示文本)的应该有:
warn.Caption
typetri.Caption
s.Caption
l.Caption
typetri.Caption
补充
代码:
Private Sub Command1_Click() '只有一个command1
Dim a As Single, b As Single, c As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a + b <= c Then
Label1.Caption = "无法构成三角形"