473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why is this not working and how to fix??

Ron
I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub

Jan 22 '07 #1
9 1045
Suppose you give us a hint about what it's not doing right?

Tom Dacon
Dacon Software Consulting

"Ron" <pt*****@yahoo.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
>I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub

Jan 22 '07 #2
Change:

Dim i As Integer = 1900

to:

Dim i As Integer = 1901

otherwise you are starting at 1900 instead of 1901.

Delete the 2 lines:

Do
Loop

otherwie you have an endless loop.

Change:

While i < 2099

to:

While i <= 2099
otherwise you are ending at 2098 instead of 2099.

Move the line:

While i <= 2099

to directly before the line:

a = (i) Mod 19

otherwise you are prodicing the same result for every year.

Move the line:

i = i + 1

to directly before the line:

End While

to make the loop work correctly.

And ... Voila!
"Ron" <pt*****@yahoo.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
>I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub

Jan 22 '07 #3
Anyone know of a way to convert a HTML Table to CSV or Datatable? It's in
the form of this format It's basically a multi row x 7 column HTML table...
all in standard HTML <TABLEtags thanks!


"Ron" <pt*****@yahoo.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
>I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub

Jan 22 '07 #4
whoops posted to wrong spot

"Smokey Grindel" <no****@nospam.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
Anyone know of a way to convert a HTML Table to CSV or Datatable? It's in
the form of this format It's basically a multi row x 7 column HTML
table... all in standard HTML <TABLEtags thanks!


"Ron" <pt*****@yahoo.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
>>I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub


Jan 22 '07 #5
Only if you want the dates of easter in it.

Try starting a new thread, giving your post a meaningful subject line and
punctuating your post so that ic can be understood.
"Smokey Grindel" <no****@nospam.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
Anyone know of a way to convert a HTML Table to CSV or Datatable? It's in
the form of this format It's basically a multi row x 7 column HTML
table... all in standard HTML <TABLEtags thanks!


"Ron" <pt*****@yahoo.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
>>I am trying to populate a listbox with dates of easter from 1901 to
2099. My code is not doing it. Here is what I have. What am I doing
wrong?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Dim b As Integer = 0
Dim c As Integer = 0
Dim d As Integer = 0
Dim g As Integer = 0
Dim easter As Integer = 0
Dim easterinapril As Integer = 0
Dim i As Integer = 1900

a = (i) Mod 19
b = i Mod 4
c = i Mod 7
d = (19 * a + 24) Mod 30
g = (2 * b + 4 * c + 6 * d + 5) Mod 7

easter = (22 + d + g)
easterinapril = (easter - 31)
Do
While i < 2099
If easter 31 Then
lstResult.Items.Add("April " & easterinapril & ", "
& i)
Else : lstResult.Items.Add("March " & easter & ", " &
i)
End If
End While
i = i + 1

Loop

End Sub


Jan 22 '07 #6
"Stephany Young" <noone@localhostwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
And ... Voila!
Yet it apparently still does not compute Easter :-)

http://en.wikipedia.org/wiki/Computus

From what I can see the OP is suing "Gauss's algorithm" (though not exactly)
which contains (according to Wikipedia) two exception dates. And as it
points out requires a table (which is why the OP is limited to dates between
1900 and 2099). Other ranges require other magic numbers.

If the OP reads the link above (or perhaps he has) he might want to test the
Meeus Julian algorithm which is "valid for all Julian years and has no
exceptions and requires no tables" which sounds like a plus to me.

Tom
Jan 22 '07 #7
Absolutely Tom!

Note that I did not comment on the validity of the algorithm the OP was
using (the Meeus Julian algorithm), but for the year range 1901 to 2099, it
does actually get it right. Off the top of my head I think it works for that
range because 2000 was a leap year, but it will not probably not work 1900
because that wasn't a leap year (2100 is isn the same boat).

I use the Meeus/Jones/Butcher Gregorian algorithm which is valid for all
Gregorian years, but one still has to be careful for years prior to 1753
because down in this part of the world we use the Gregorian calandar as
adopted by Great Britain in 1752 as a result of the Calandar Act of 1751. In
Italy and Spain (and some other countries) it will be good for years later
than 1582.

Of course it is only good until such time as we change the calendar again.
:)

"Tom Leylan" <tl*****@nospam.netwrote in message
news:OX**************@TK2MSFTNGP03.phx.gbl...
"Stephany Young" <noone@localhostwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>And ... Voila!

Yet it apparently still does not compute Easter :-)

http://en.wikipedia.org/wiki/Computus

From what I can see the OP is suing "Gauss's algorithm" (though not
exactly) which contains (according to Wikipedia) two exception dates. And
as it points out requires a table (which is why the OP is limited to dates
between 1900 and 2099). Other ranges require other magic numbers.

If the OP reads the link above (or perhaps he has) he might want to test
the Meeus Julian algorithm which is "valid for all Julian years and has no
exceptions and requires no tables" which sounds like a plus to me.

Tom


Jan 22 '07 #8
To add a little bit for your knowledge in New Zealand.
I use the Meeus/Jones/Butcher Gregorian algorithm which is valid for all
Gregorian years, but one still has to be careful for years prior to 1753
because down in this part of the world we use the Gregorian calandar as
adopted by Great Britain in 1752 as a result of the Calandar Act of 1751.
In Italy and Spain (and some other countries) it will be good for years
later than 1582.
Before 1583 had all Major European countries of those days beside England
and Turkey adopted the Gregorian calendar.

Those included Spain, France, Polen/Lituanien, Holland/Zeeland.


Jan 22 '07 #9
Ron
thanks for all the help everyone. Ok so there are exception years and
I am trying to write this code in for the exception years, anyone see
what i am doing wrong:

easter = (22 + d + g)
easterinapril = (easter - 31)
easterspecialyear = (easter - 7)

'for years 1954, 1981...etc. use this (easter-7) or (22+d+g)-(7))
'the below does not work, do i need it somewhere else in my if
statements to make this work correctly?

If CInt(txtYear.Text) = 1954 Or CInt(txtYear.Text) = 1981 Or
CInt(txtYear.Text) = 2049 Or CInt(txtYear.Text) = 2076 Then
lblResult.Text = easterspecialyear
Else
If CInt(txtYear.Text) < 1901 Or CInt(txtYear.Text) 2099
Then
lblResult.Text = "Please enter a valid year"
ElseIf easter 31 Then
lblResult.Text = "Easter in the year " & txtYear.Text &
" " & "is on April " & easterinapril
Else
lblResult.Text = "Easter in the year " & txtYear.Text &
" " & "is on March " & easter
End If
End If
End Sub

On Jan 22, 1:38 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
To add a little bit for your knowledge in New Zealand.
I use the Meeus/Jones/Butcher Gregorian algorithm which is valid for all
Gregorian years, but one still has to be careful for years prior to 1753
because down in this part of the world we use the Gregorian calandar as
adopted by Great Britain in 1752 as a result of the Calandar Act of 1751.
In Italy and Spain (and some other countries) it will be good for years
later than 1582.Before 1583 had all Major European countries of those days beside England
and Turkey adopted the Gregorian calendar.

Those included Spain, France, Polen/Lituanien, Holland/Zeeland.
Jan 26 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: zalekbloom | last post by:
I noticed on my PC with win98/IE 6.028 applets are not working. Applets are working when I use Netscape 7.1. When I open the DOS win and I check for a Java version I am getting: C:\WINDOWS>java...
5
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular...
3
by: S. van Beek | last post by:
Dear reader, To work with linked tables is a professional method of working with a frond end and back end mdb. Working with linked tables on a local pc gives an acceptable performance but...
6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
0
by: Mark B | last post by:
Our webhost (www.usbusinessweb.net) had a W2K IIS5 server crash after a scheduled hard-boot occurred during a ms-security patch install overnight. They couldn't get the server working again so they...
1
by: Larry Bud | last post by:
Wondering what I should be looking at when looking for a memory leak.. Using Process Explorer by SysInternals, and they have a Working Set and a Virtual Size memory column. Which one should I be...
10
by: sp | last post by:
The application is written in Visual Basic / .NET and working without problems under Windows XP, Windows 2000, Windows 2003 but it isn't working under Windows ME and Windows 98 - the computer...
0
by: George2 | last post by:
Hello everyone, From the definition of working set, it is a subset of virtual pages resident in physical memory -- from book Windows Internals. It means working set could not be larger than...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.