Dim Date1 As Date, Date2 As Date
Date1 = "01/01/1000"
Date2 = "12/31/9999"
'number of days between dates
Dim iDiff = DateDiff("d", Date1, Date2, vbMonday)
Dim RndDate As Date
Randomize()
RndDate = DateAdd("d", Int((iDiff * Rnd()) + 1), Date1)
Label2.Text = RndDate
Random date generator
Page 1 of 11 Replies - 1229 Views - Last Post: 30 March 2012 - 09:44 AM
#1
Random date generator
Posted 30 March 2012 - 09:10 AM
Hey! Im doing a project where the computer generate a random date and the user has to guess what day of the week it lands on. I have the random generator but I would like to change it where the month is not a integer . . . For example, March 30, 2012 instead of 3/30/2012. Here is my code so far . . .
Replies To: Random date generator
#2
Re: Random date generator
Posted 30 March 2012 - 09:44 AM
Look at the Methods for DateTime
There are methods for converting "03/30/2012" to "March 30, 2012"
RndDate.
Will open the intellisense window where you can see properties and methods that will help you with this.
If you don't like any of those options, you also have the ability of formatting it with the .ToString() method to better suit your needs.
There are methods for converting "03/30/2012" to "March 30, 2012"
RndDate.
Will open the intellisense window where you can see properties and methods that will help you with this.
If you don't like any of those options, you also have the ability of formatting it with the .ToString() method to better suit your needs.
This post has been edited by CharlieMay: 30 March 2012 - 09:53 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|