Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 31st, 2009, 07:31 AM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default How can i get full months date

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.


Reply With Quote
  #2 (permalink)  
Old January 31st, 2009, 04:45 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Something like this:
Code:
' 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

Dim firstOfMonth As Date, lastOfMonth As Date
firstOfMonth = DateSerial( yearNum, monthNum, 1 )
lastOfMonth = DateSerial( yearNum, monthNum+1, 0 )
For myDate = firstOfMonth To lastOfMonth
    Dim oneDate As String
    oneDate = Right("0" & Day(myDate),2) & "-" & MonthName(Month(myDate),True) _
                & Right(CStr(Year(myDate)),2) & " " & WeekdayName(Weekday(myDate))
    ... do something with "oneDate" ...
Next
It's been 10 years since I played with VB6, but I think that's right.
Reply With Quote
  #3 (permalink)  
Old February 1st, 2009, 07:38 AM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Hello Pedent,

Thank you very much. You just push me one step ahead to my project being done. How will i place the "oneDate" value in 31 level. Should i make control array or how will i do that??

As i mentioned earlier, I'm very new in VB 6. You played 10 years but i have started playing since 7 months.

Please help me for "oneDate".
Reply With Quote
  #4 (permalink)  
Old February 1st, 2009, 06:13 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Sorry, but I don't know what you mean by "... in 31 level."

You mean into the 31 options of the combo box???

Sorry, but I just don't remember that, at all. If you can use an array to populate a combo box, then yes, creating an array from that code would work fine.
Code:
' 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

Dim firstOfMonth As Date, lastOfMonth As Date
firstOfMonth = DateSerial( yearNum, monthNum, 1 )
lastOfMonth = DateSerial( yearNum, monthNum+1, 0 )
Dim arrayOfDates 
ReDim arrayOfDates( Day(lastOfMonth) - 1 )
For myDate = firstOfMonth To lastOfMonth
    Dim oneDate As String
    oneDate = Right("0" & Day(myDate),2) & "-" & MonthName(Month(myDate),True) _
                & Right(CStr(Year(myDate)),2) & " " & WeekdayName(Weekday(myDate))
    arrayOfDates( Day(myDate) - 1 ) = oneDate
Next
SOMETHING like that, at least.
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
devilz (February 2nd, 2009)
  #5 (permalink)  
Old February 2nd, 2009, 02:00 PM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default


Hello Pedant,

Thank you very much for the reply. Sorry Pedant i made you confuse. Actually i keep 31 individual Label(control) in the form for displaying all the month dates in its CAPTION. Its like

Label1 will contain date1
Label2 will contain date2
.
.
.
.
.
Label31 will contain date31.

Will you please help me?
Reply With Quote
  #6 (permalink)  
Old February 3rd, 2009, 01:54 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I just don't remember <FORM>s in VB6. Most of what I did was create COM DLLs for use by ASP pages, so we weren't creating any ".exe"s and of course that meant no <FORM>s.

If you could show some code as to how you create a label, *maybe* it will help me remember enough.
Reply With Quote
  #7 (permalink)  
Old February 3rd, 2009, 07:29 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Coming to the rescue ;)

Do you have your labels in a collection (with index, all the same name)?

I hope you, that way the only thing you have to do is

Code:
 labeldate(1).caption = oneday
if you don´t have a collection of controls, then you will need to do a select case (or an if) and write the code to fill every control by itself. I hope you can go to the first method :)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
The Following User Says Thank You to gbianchi For This Useful Post:
devilz (February 3rd, 2009)
  #8 (permalink)  
Old February 3rd, 2009, 02:01 PM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default Hello Pedant

Dear Pedant,

Again Thank you very much for the reply. You are playing with VB for the last 10 years but I’m still in the beginning stage of VB. My project purpose is to make “Roster duty”. I took a standard exe form where I placed label, text box, combo box from the toolbar. One combo box is containing month and another combo box containing year. When a month will be selected by user the date for that month will be displayed in different 31 Labels.

Name
March
2009
Sat
Sun
Mon
Tues
Wed
Thurs
Fri





1
2





Morning
Morning
3
4
5
6
7
8
9
Evening
Evening
Night
Off
Off
Morning
Morning
10
11
12
13
14
15
16
Evening
Evening
Night
Off
Off
Morning
Morning
17
18
19
20
21
22
23
Evening
Evening
Night
Off
Off
Morning
Morning
24
25
26
27
28
29
30
Evening
Evening
Night
Off
Off
Morning
Morning
31

Evening



1, 2, 3, 4… which are representing dates of March(selected in combo box).All the dates are displaying in label caption. Instead of 1, 2, 3, 4, .. I want to display the full date which I get from your help. Now the problem is all the dates which I’m getting from the loop how will I place all the individual date in individual label caption??? Time is running out. If you could manage time please help me regarding it, Please Pedant help me.
Reply With Quote
  #9 (permalink)  
Old February 4th, 2009, 03:27 AM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I think GBianchi will be better able to help you than I.

I'm afraid I don't really even understand the question.

May I ask why you are starting to learn VB6 *NOW*??? VB6 is very badly OBSOLETE. Microsoft replaced in 2001 with VB.NET, and VB.NET is a *MUCH* better language and much more "up to date". It's also free. (Or at least the "Express" edition is.) And it has some wonderful FREE tutorials.
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
devilz (February 10th, 2009)
  #10 (permalink)  
Old February 10th, 2009, 07:17 AM
Authorized User
Points: 88, Level: 1
Points: 88, Level: 1 Points: 88, Level: 1 Points: 88, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Default Hello Pedant

Hello Pedant,

Sorry for late reply and for my last post. I wrote it as table was the mistake. You said right. VB 6.0 is obsolate. Surely i will start learning VB.NET right after completing my current project.

Now i can generate full month date which might not possible without your help. In this regard, again THANK YOU VERY MUCH FOR THE SUPPORT.

If i face any more problem then surely i'll knock you. I hope you wont mind to help me!!!

Take care.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
display all dates within months sanjeev jha Classic ASP Basics 1 June 6th, 2008 12:46 PM
date conversion in years, months and days naveed77 Beginning VB 6 0 January 2nd, 2008 01:18 AM
T-SQL Code to get last 6 months midway11 SQL Language 1 October 15th, 2006 08:59 AM
Years to Months Conversion mahajanvit ASP.NET 2.0 Basics 2 September 25th, 2006 11:43 PM
Find months difference tsimsha Classic ASP Databases 4 February 14th, 2005 08:36 PM



All times are GMT -4. The time now is 04:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.