'我做了一个生成时间范围值和随机提取单个时间值例子,供你参考自动生成时间范围值和随机提取单一时间值
Private Sub Command0_Click()
Dim i As Long
Dim sj As Date
If Not IsNull(Me.开始时间值) And Not IsNull(Me.结束时间值) Then
sj = 开始时间值
Me.时间值.RowSource = ""
Me.时间值.RowSource = Me.时间值.RowSource & 0 & ";"
Me.时间值.RowSource = Me.时间值.RowSource & 开始时间值 & ";"
For i = 1 To 10 * 60 - 1 Step 1
sj = sj + 1 / 24 / 60 / 60
Me.时间值.RowSource = Me.时间值.RowSource & i & ";"
Me.时间值.RowSource = Me.时间值.RowSource & sj & ";"
Next
Else
MsgBox "请设置开始时间和结束时间值"
End If
Me.时间值.Requery
End Sub
Private Sub Command6_Click()
If Len(Me.时间值.RowSource) > 0 Then
Dim SJsz As Long
SJsz = Int((1 - 599 + 1) * Rnd + 599)
MsgBox "提取指定范围随机时间值:" & Me.时间值.Column(1, SJsz)
End If
End Sub