| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

a = "10:18 11:49 13:37 15:09 19:48 "
b = "08:29 18:19 18:20 18:23 "
c = "08:39 08:41 07:21 08:30 08:20 19:47 08:47 "
d = "14:48 16:07 15:48 19:20 14:10 00:00 "

a---min:10:18---max:19:48
b---min:08:29---max:18:23
c---min:07:21---max:19:47
d---min:14:10---max:00:00

listbox 支持排序，

```Option Explicit

'窗体上放一个 listbox1 ，sotred 属性设为了 true
Private Type jg
a As Variant
b As Variant
End Type

Private Sub Command1_Click()
Dim j As jg
Dim a, b, c, d
a = "10:18 11:49 13:37 15:09 19:48 "
b = "08:29 18:19 18:20 18:23 "
c = "08:39 08:41 07:21 08:30 08:20 19:47 08:47 "
d = "14:48 16:07 15:48 19:20 14:10 00:00 "

j = minmax(a)
Print j.a, j.b
j = minmax(b)
Print j.a, j.b
j = minmax(c)
Print j.a, j.b
j = minmax(d)
Print j.a, j.b

End Sub

Private Function minmax(s As Variant) As jg
Dim f() As String
Dim i As Long
f = Split(s, " ")
List1.Clear
For i = 0 To UBound(f)
If Len(f(i)) > 0 Then
End If
Next i
minmax.a = List1.List(0)
minmax.b = List1.List(List1.ListCount - 1)
End Function
```

listbox 支持排序，

Option Explicit

'窗体上放一个 listbox1 ，sotred 属性设为了 true
Private Type jg
a As Variant
b As Variant
End Type

Private Sub Command1_Click()
Dim j As jg
Dim a, b, c, d
a = "10:18 11:49 13:37 15:09 19:48 "
b = "08:29 18:19 18:20 18:23 "
c = "08:39 08:41 07:21 08:30 08:20 19:47 08:47 "
d = "14:48 16:07 15:48 19:20 14:10 00:00 "

j = minmax(a)
Print j.a, j.b
j = minmax(b)
Print j.a, j.b
j = minmax(c)
Print j.a, j.b
j = minmax(d)
Print j.a, j.b

End Sub

Private Function minmax(s As Variant) As jg
Dim f() As String
Dim i As Long
f = Split(s, " ")
List1.Clear
For i = 0 To UBound(f)
If Len(f(i)) > 0 Then
End If
Next i
minmax.a = List1.List(0)
minmax.b = List1.List(List1.ListCount - 1)
End Function

```Sub Test()
Dim t(3) As String
a = "10:18 11:49 13:37 15:09 19:48 "
b = "08:29 18:19 18:20 18:23 "
c = "08:39 08:41 07:21 08:30 08:20 19:47 08:47 "
d = "14:48 16:07 15:48 19:20 14:10 00:00 "
With CreateObject("msscriptcontrol.scriptcontrol")
.Language = "javascript"
t(0) = "a=" & .eval("s('" & Trim(a) & "')")
t(1) = "b=" & .eval("s('" & Trim(b) & "')")
t(2) = "c=" & .eval("s('" & Trim(c) & "')")
t(3) = "d=" & .eval("s('" & Trim(d) & "')")
End With
MsgBox Join(t, vbCrLf)
End Sub
```

c = "08:39 08:41 07:21 08:30 08:20 19:47 08:47 "

• 6
• 1/1页
• 1