Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 2nd, 2004, 09:05 AM
ChromeX's Avatar
ChromeX ChromeX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Italy
Posts: 63 ChromeX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 7 sec
Reputation Power: 10
Red face Alternate Weeks - Please, help someone :(

Hello, i just used this code:
Code:
procedure TForm1.TBXLink1Click(Sender: TObject);
begin
ListBox1.Clear;
ListBox1.Items.Add(' English');
ListBox1.Items.Add(' RE');
ListBox1.Items.Add(' Geography');
ListBox1.Items.Add(' Maths');
ListBox1.Items.Add(' English');
ListBox1.Items.Add(' Science');
end;

procedure TForm1.TBXLink2Click(Sender: TObject);
begin
ListBox1.Clear;
ListBox1.Items.Add(' PE');
ListBox1.Items.Add(' French');
ListBox1.Items.Add(' Maths');
ListBox1.Items.Add(' Tech');
ListBox1.Items.Add(' Science');
ListBox1.Items.Add(' Art');
end;
...
procedure TForm1.FormCreate(Sender: TObject);
var
C: HCURSOR;
myDate : TDateTime;
day    : array[1..7] of string;
formattedDateTime: string;
begin
C := LoadCursor(0, IDC_HAND);
  if C <> 0 then Screen.Cursors[crHandPoint] := C;
myDate := Date;

  day[1] := 'Monday';
  day[2] := 'Tuesday';
  day[3] := 'Wednesday';
  day[4] := 'Thursday';
  day[5] := 'Friday';
  day[6] := 'Saturday';
  day[7] := 'Sunday';

DateTimeToString(formattedDateTime, 'dd/mm/yyyy', myDate);
TBXLabel3.Caption := formattedDateTime;

if (DayOfTheWeek(myDate)=1) then
begin
TBXLink1Click(Sender);
...
...
end.

To obtain the different items in the ListBox Each Day. now i need to make an alternate weeks, for example:

Week 1 day 1 i got
xxx
xxx
xxx
...
Week1 day 5 i got
xxx
xxx
...
now switching to the next week

Week2 day 1 i got
xxx
xxx....
till day5

How is it possible? I mean How can i add an internal counter to the app that counta the weeks, so if the week 1 is finished, it begins to display the days of the week 2 and so on ?

Last edited by ChromeX : May 2nd, 2004 at 11:38 AM.

Reply With Quote
  #2  
Old May 2nd, 2004, 11:36 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 5 m 43 sec
Reputation Power: 4080
Yes. You forgot to initilialize myDate.
Code:
procedure TForm1.FormCreate(Sender: TObject);
var
myDate : TDateTime;
day    : array[1..7] of string;
formattedDateTime: string;
begin
   myDate := Now;
   DateTimeToString(formattedDateTime, 'dddd d of mmmm yyyy', myDate);
  ShowMessage('dddd d of mmmm yyyy = '+formattedDateTime);
...
...
end;
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
  #3  
Old May 2nd, 2004, 11:40 AM
ChromeX's Avatar
ChromeX ChromeX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Italy
Posts: 63 ChromeX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 7 sec
Reputation Power: 10
Scorpions4ever: thank you for your reply, i dont it already, so i have modified my topic... could you help me with that one issue? read the 1st post

Reply With Quote
  #4  
Old May 3rd, 2004, 11:50 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 5 m 43 sec
Reputation Power: 4080
I'm not certain exactly what you want here. Could you please explain what the output should look like.

Reply With Quote
  #5  
Old May 3rd, 2004, 02:11 PM
ChromeX's Avatar
ChromeX ChromeX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Italy
Posts: 63 ChromeX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 7 sec
Reputation Power: 10
Quote:
Originally Posted by Scorpions4ever
I'm not certain exactly what you want here. Could you please explain what the output should look like.

well, I got the app that has displays the different strings in the listbox each day for one week; when the 1st week will be finished, the 2nd week will be displayed items in the listbox but different from the ones from the 1st week; when the 2nd week will be finished, it will display again the items of the 1st week...Here is the screenshots:
http://chrome.topcities.com/scr1.gif
http://chrome.topcities.com/scr2.gif

Could you understand me now?

Reply With Quote
  #6  
Old May 4th, 2004, 12:30 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 5 m 43 sec
Reputation Power: 4080

Reply With Quote
  #7  
Old May 4th, 2004, 09:29 AM
ChromeX's Avatar
ChromeX ChromeX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Italy
Posts: 63 ChromeX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 7 sec
Reputation Power: 10
uhm, it's not exactly what i'm searchig for I meaned to use only 2 weeks every month for ex Week1 has the days (1-7 with any items in the listbox), then goes the Week2 with the same days but different items in the listbox, then again the Week1 and then the week2. Finished the month, new one begins and the Week1 starts again, the the Week2 etc... The example you gave me on the sites has just the week numbers for the whole year.
In this list ( i need it for school)
I have maths on monday, the week after on monday i might not have maths because its a different week for eg
Monday Week 1:
Maths, PE, Science etc
Monday week 2:
Art, georgraphy, ICT
and it alternates like that.
Here is the PAS unit if you'd like to see it:
Attached Files
File Type: txt Unit1.txt (6.8 KB, 592 views)

Last edited by ChromeX : May 4th, 2004 at 09:44 AM.

Reply With Quote
  #8  
Old May 5th, 2004, 12:44 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 5 m 43 sec
Reputation Power: 4080
Ok, I think I'm beginning to understand what you need. The problem is very simple then. All you need to do is figure out the week number of the year and then do a modulo division by 2 on that number. This will give you either a 1 or a 0 depending on whether it is an odd or an even week number. You can use DecodeDateWeek and as a bonus, it also gives you the day of the week, so you don't need to call DayOfTheWeek multiple times.
Code:
private
    { Private declarations }
    myDate: TDateTime;
    AYear, AWeek, ADay, WeekNum : Word;
....
...

procedure TForm1.FormCreate(Sender: TObject);
begin
    ....
    myDate := Now;
    DecodeDateWeek(myDate, AYear, AWeek, ADay);
    WeekNum := AWeek Mod 2; // WeekNum is either 0 or 1
    ....
    if (ADay == 1) then
    begin
        TBXLink1Click(Sender);
        Form1.Caption := ver+' - '+day[DayOfTheWeek(myDate)];
        TBXLink1.Font.Color := clRed;
        TBXLink2.Font.Color := clHotLight;
         ....
    end
    else if (ADay = 2) then
    begin
    ....
    end
end;

procedure TForm1.TBXLink1Click(Sender: TObject);
begin
  ListBox1.Clear;
  if (WeekNum = 0) then
  begin
    ListBox1.Items.Add(' English');
    ListBox1.Items.Add(' RE');
    ListBox1.Items.Add(' Geography');
    ListBox1.Items.Add(' Maths');
    ListBox1.Items.Add(' English');
    ListBox1.Items.Add(' Science');
  end
  else begin
    ListBox1.Items.Add(' Geography');
    ListBox1.Items.Add(' English');
    ListBox1.Items.Add(' English');
    ListBox1.Items.Add(' RE');
    ListBox1.Items.Add(' Science');
    ListBox1.Items.Add(' Maths');
  end
end;

Reply With Quote
  #9  
Old May 5th, 2004, 04:20 AM
ChromeX's Avatar
ChromeX ChromeX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Italy
Posts: 63 ChromeX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 7 sec
Reputation Power: 10
thank you! that's what i was searching for!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Wrong Date

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap