Strike_Eagle
Registered User.
- Local time
- , 19:13
- Joined
- Oct 20, 2011
- Messages
- 48
Hello everyone and thank you for taking the time to view this posting.
I am using Access 2010 and have created a randomizer for dates that store in an array and then display those dates in a text box. It works great except that when it displays the results a time is shown then the correct number of dates that were randomized. How do I get the time to stop displaying on the text box display? Following is the code and output, please enjoy pointing out my, probably obvious, mistake!
Display:
12:00:00 AM
4/26/2013
4/9/2013
4/23/2013
4/27/2013
4/24/2013
4/1/2013
4/3/2013
4/12/2013
4/24/2013
I am using Access 2010 and have created a randomizer for dates that store in an array and then display those dates in a text box. It works great except that when it displays the results a time is shown then the correct number of dates that were randomized. How do I get the time to stop displaying on the text box display? Following is the code and output, please enjoy pointing out my, probably obvious, mistake!
Code:
Public Function GetRandomDate(lowerDate As Date, upperDate As Date) As Date
Randomize
GetRandomDate = Int((upperDate - lowerDate + 1) * Rnd + lowerDate)
Debug.Print GetRandomDate
End Function
Code:
Private Sub rButton_Click()
Dim lowerDate As Date
Dim upperDate As Date
Dim randomDate As Date
Dim dateArray() As Date
Dim dateCount As Integer
Dim i As Integer
Dim d As Integer
lowerDate = Me.startDate.Value
upperDate = Me.endDate.Value
dateCount = Me.numberOfDaysToRandomize.Value
For i = 1 To dateCount
randomDate = GetRandomDate(lowerDate, upperDate)
ReDim Preserve dateArray(i)
dateArray(i) = randomDate
Next i
Me.displayDatesTextBox.Value = ""
For d = 0 To dateCount
Me.displayDatesTextBox.Value = Me.displayDatesTextBox.Value & dateArray(d) & vbNewLine
Next d
End Sub
Display:
12:00:00 AM
4/26/2013
4/9/2013
4/23/2013
4/27/2013
4/24/2013
4/1/2013
4/3/2013
4/12/2013
4/24/2013
Last edited: