早教吧 育儿知识 作业答案 考试题库 百科 知识分享

求做一道VB题求两个数最大值与最小值的Function过程,并条用这两个过程分别求3,5,7个数的最大值和最小值并输出

题目详情
求做一道VB题
求两个数最大值与最小值的Function过程,并条用这两个过程分别求3,5,7个数的最大值和最小值并输出
▼优质解答
答案和解析
Private Function max(ByVal a As Integer, ByVal b As Integer) As Integer
If a > b Then max = a Else max = b
End Function
Private Function min(ByVal a As Integer, ByVal b As Integer) As Integer
If a > b Then min = b Else min = a
End Function
Private Sub Command1_Click()
Dim a, b, c
a = 3
b = 5
c = 7
Print a; b; c; "中最大数为:"; max(a, max(b, c))
Print a; b; c; "中最小数为:"; min(a, min(b, c))
End Sub