Minh Tiên > 17-12-13, 04:20 PM
Xuân Thanh > 17-12-13, 09:28 PM
Function TimMinMax(strArr As String)
Dim MinArr, MaxArr
Dim Arr, Msg
Arr = Split(strArr, ",")
MinArr = Arr(0): MaxArr = Arr(0)
Dim i As Long
For i = 0 To UBound(Arr)
If MaxArr < Arr(i) Then MaxArr = Arr(i)
If MinArr > Arr(i) Then MinArr = Arr(i)
Next
Msg = MsgBox("So nho nhat la " & MinArr & " va so lon nhat la " & MaxArr)
TimMinMax = Msg
End Function
Minh Tiên > 18-12-13, 09:11 PM
Private Function GetMinMaxValues(strArr As String, Optional bGetMax As Boolean = False) As Integer
Dim iCounter
Dim Ary
Ary = Split(strArr, ",")
GetMinMaxValues = Ary(0) 'set to the first one so it's not empty
For iCounter = 0 To UBound(Ary)
If (GetMinMaxValues < Trim(Ary(iCounter))) Xor bGetMax Then
GetMinMaxValues = Trim(Ary(iCounter))
End If
Next
End Function
'Call Function:
'Min: GetMinMaxValues(strArr, True)
'Max: GetMinMaxValues(strArr)
Private Function GetMinMaxDays(strArr As String, Optional bGetMax As Boolean = False) As Date
Dim iCounter
Dim Ary
Ary = Split(strArr, ",")
GetMinMaxDays = Ary(0) 'set to the first one so it's not empty
For iCounter = 0 To UBound(Ary)
If (GetMinMaxDays < Trim(Ary(iCounter))) Xor bGetMax Then
GetMinMaxDays = Trim(Ary(iCounter))
End If
Next
End Function
'Call Function:
'Min: GetMinMaxDays(strArr, True)
'Max: GetMinMaxDays(strArr)