vb程序设计教程答案 15
我是初学者 望高手指点迷津 谢谢 展开
Private Sub Command1_Click()
If Val(Text1.Text) < Val(Text2.Text) Then
Label1.Caption = "最小数:" & IIf(Val(Text1.Text) < Val(Text3.Text), Text1.Text, Text3.Text)
Label2.Caption = "最大数:" & IIf(Val(Text2.Text) < Val(Text3.Text), Text3.Text, Text2.Text)
Else
Label1.Caption = "最小数:" & IIf(Val(Text2.Text) < Val(Text3.Text), Text2.Text, Text3.Text)
Label2.Caption = "最大数:" & IIf(Val(Text1.Text) < Val(Text3.Text), Text3.Text, Text1.Text)
End If
End Sub
参考资料: vb专业解答团 http://zhidao.baidu.com/team/view/VB%D7%A8%D2%B5%BD%E2%B4%F0%CD%C5
再插入两个label控件label1、label2用于显示最大值与最小值
最后插入一个button控件
双击button控件输入以下代码即可
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = CInt(TextBox3.Text)
If a > b And b > c Then
Label1.Text = CStr(a)
Label2.Text = CStr(c)
End If
If a > c And c > b Then
Label1.Text = CStr(a)
Label2.Text = CStr(b)
End If
If b > a And a > c Then
Label1.Text = CStr(b)
Label2.Text = CStr(c)
End If
If b > c And c > a Then
Label1.Text = CStr(b)
Label2.Text = CStr(a)
End If
If c > b And b > a Then
Label1.Text = CStr(c)
Label2.Text = CStr(a)
End If
If c > a And a > b Then
Label1.Text = CStr(c)
Label2.Text = CStr(b)
End If
End Sub
可能有更简便的方法
ABC赋值 文本框.
在用判断语句
判断那个数值比较大...
判断之后赋值abc为标签的标题.
结束判断语句