943,877 Members | Top Members by Rank

Ad:
Jan 27th, 2009
0

how can i get full months date

Expand Post »
I’m very very new in VB6.0 in my project I need a function where I want to pass month name as variable value which will be selected from a combo box by user and the function will generate the full date from starting to end along with the weekday name.

Suppose user select the month “JANUARY” and year from different combo box. Under combo box click event that function will work and will generate the valid date from 1st January to 31th January along with the weekday name. like:

01-Jan-09 Thursday, 02-Jan-09 Friday, 03-Jan-09 Saturday, 04-Jan-09 Sunday, 05-Jan-09 Monday, 06-Jan-09 Tuesday, 07-Jan-09 Wednesday, 08-Jan-09 Thursday, 09-Jan-09 Friday, 10-Jan-09 Saturday, 11-Jan-09 Sunday, 12-Jan-09 Monday, 13-Jan-09 Tuesday, 14-Jan-09 Wednesday, 15-Jan-09 Thursday, 16-Jan-09 Friday, 17-Jan-09 Saturday, 18-Jan-09 Sunday, 19-Jan-09 Monday, 20-Jan-09 Tuesday, 21-Jan-09 Wednesday, 22-Jan-09 Thursday, 23-Jan-09 Friday, 24-Jan-09 Saturday, 25-Jan-09 Sunday, 26-Jan-09 Monday, 27-Jan-09 Tuesday, 28-Jan-09 Wednesday, 29-Jan-09 Thursday, 30-Jan-09 Friday, 31-Jan-09 Saturday.

LevelText of 31 unique level (control) will display those dates. All the date must be valid. I’m requesting all of my seniors, plz plz help me.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
devilz is offline Offline
14 posts
since Jan 2009
Jan 27th, 2009
0

Re: how can i get full months date

1. select the month.
2. findout all the dates.
3. findout the days by passing the dates ---use WEEKDAYNAME function for the purpose.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Jan 27th, 2009
0

Re: how can i get full months date

Yes, Debasisdas is correct.
Refer

WeekDayName ()
WeekDay ()
&
Other Date Functions
to achieve this.

WeekDayName ( WeekDay ( Date ) ) returns today date in String
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jan 31st, 2009
0

Re: how can i get full months date

Click to Expand / Collapse  Quote originally posted by debasisdas ...
1. select the month.
2. findout all the dates.
3. findout the days by passing the dates ---use WEEKDAYNAME function for the purpose.
Dear debasis,

As i have mentioned i'm very new in VB and your profile says that you are much experienced. Can you give me some example or some sample coding which will meet the needful? Please bro, I need it.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
devilz is offline Offline
14 posts
since Jan 2009
Jan 31st, 2009
0

Re: how can i get full months date

Dear Salvaganapathy,

Please help me in details. Can you help me with some sample coding. Please....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
devilz is offline Offline
14 posts
since Jan 2009
Feb 4th, 2009
0

Re: how can i get full months date

go here. http://www.vb6.us/tutorials/formatin...-and-times-vb6
it gives different date formats and examples
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Feb 7th, 2009
0

Re: how can i get full months date

Hi,

Try This Code:

vb Syntax (Toggle Plain Text)
  1. Dim FromDate As Date
  2. Dim ToDate As Date
  3. Dim TempDate As Date
  4. Combo1.clear
  5. FromDate = DateSerial(Val(cmbYear.Text), (CmbMonth.ListIndex+1), 1)
  6. ToDate = DateAdd("m", 1, FromDate)
  7. ToDate = ToDate - 1
  8. TempDate = FromDate
  9. For TempDate = FromDate To ToDate
  10. Combo1.AddItem (Format(TempDate, "dd-mm-yyyy") & " " _
  11. & WeekdayName(Weekday(TempDate)))
  12. Next

Populate Months in Combobox in the Ascending Order(Jan, Feb, Mar...), and keep Sorted of ComboMonth = False

Regards
Veena
Last edited by QVeen72; Feb 7th, 2009 at 10:42 pm.
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Feb 14th, 2009
0

Re: how can i get full months date

Click to Expand / Collapse  Quote originally posted by QVeen72 ...
Hi,

Try This Code:

vb Syntax (Toggle Plain Text)
  1. Dim FromDate As Date
  2. Dim ToDate As Date
  3. Dim TempDate As Date
  4. Combo1.clear
  5. FromDate = DateSerial(Val(cmbYear.Text), (CmbMonth.ListIndex+1), 1)
  6. ToDate = DateAdd("m", 1, FromDate)
  7. ToDate = ToDate - 1
  8. TempDate = FromDate
  9. For TempDate = FromDate To ToDate
  10. Combo1.AddItem (Format(TempDate, "dd-mm-yyyy") & " " _
  11. & WeekdayName(Weekday(TempDate)))
  12. Next

Populate Months in Combobox in the Ascending Order(Jan, Feb, Mar...), and keep Sorted of ComboMonth = False

Regards
Veena
Hi Sweetheart How r u ?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
puran_ansh08 is offline Offline
1 posts
since Feb 2009
Feb 15th, 2009
0

Re: how can i get full months date

Hello veena,

Thank you very much for the support. I also found a way:


' given month number (1 through 12) and year, generate list of all days in month:
monthNum = 1 ' or wherever you get this from, e.g., from the combo box
yearNum = 2009
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim firstOfMonth As Date, lastOfMonth As Date
  2. firstOfMonth = DateSerial( yearNum, monthNum, 1 )
  3. lastOfMonth = DateSerial( yearNum, monthNum+1, 0 )
  4. For myDate = firstOfMonth To lastOfMonth
  5. Dim oneDate As String
  6. oneDate = Right("0" & Day(myDate),2) & "-" & MonthName(Month(myDate),True) _
  7. & Right(CStr(Year(myDate)),2) & " " & WeekdayName(Weekday(myDate))
  8. ... do something with "oneDate" ...
  9. Next

Thanks veena.
Last edited by Ancient Dragon; Feb 15th, 2009 at 7:04 pm. Reason: removed list tags and added code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
devilz is offline Offline
14 posts
since Jan 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: memory game problem
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Problem in Listview1





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC