The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Delphi Programming
|
Wrong Date
Discuss Wrong Date in the Delphi Programming forum on Dev Shed. Wrong Date Delphi Programming forum discussing Delphi related topics including Kylix, C++ Builder, and more. Delphi is a high-performance language, originally based on the PASCAL language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 2nd, 2004, 09:05 AM
|
 |
Contributing User
|
|
Join Date: Jun 2003
Location: Italy
Posts: 63
Time spent in forums: 43 m 7 sec
Reputation Power: 10
|
|
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.
|

May 2nd, 2004, 11:36 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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
|

May 2nd, 2004, 11:40 AM
|
 |
Contributing User
|
|
Join Date: Jun 2003
Location: Italy
Posts: 63
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 
|

May 3rd, 2004, 11:50 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
I'm not certain exactly what you want here. Could you please explain what the output should look like.
|

May 3rd, 2004, 02:11 PM
|
 |
Contributing User
|
|
Join Date: Jun 2003
Location: Italy
Posts: 63
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?
|

May 4th, 2004, 12:30 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|

May 4th, 2004, 09:29 AM
|
 |
Contributing User
|
|
Join Date: Jun 2003
Location: Italy
Posts: 63
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:
Last edited by ChromeX : May 4th, 2004 at 09:44 AM.
|

May 5th, 2004, 12:44 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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;
|

May 5th, 2004, 04:20 AM
|
 |
Contributing User
|
|
Join Date: Jun 2003
Location: Italy
Posts: 63
Time spent in forums: 43 m 7 sec
Reputation Power: 10
|
|
|
thank you! that's what i was searching for!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|