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

用vb.net求三个数中的最大值以及最小值函数的编写

题目详情
用vb.net求三个数中的最大值以及最小值函数的编写
▼优质解答
答案和解析
MaxOrMin 指示返回最大还是最小.
Private Function Math(ByVal num1 As Integer,ByVal num2 As Integer,ByVal num3 As Integer,ByVal MaxOrMin As Short) As Integer
Dim s() As Integer = {num1,num2,num3}
Dim max,min As Integer
If s(0) < s(1) Then
min = s(0)
max = s(1)
End If
If s(1) < s(2) Then
min = s(1)
max = s(2)
End If
If MaxOrMin = 0 Then Return max
If MaxOrMin = 1 Then Return min
End Function