Code works with .Net 1.1 but not .Net 2.0

Can anyone offer any suggestions as to why this code would work under .Net 1.1 and not .Net 2.0? I listed the error I receive below, also. Line 865.

Thank you,

Public Function GetAge(ByVal Birthdate As System.DateTime, _
Optional ByVal AsOf As System.DateTime = #1/1/1700#) _
As Integer
Dim iMonths As Integer
Dim iYears As Integer
Dim dYears As Decimal
Dim lDayOfBirth As Long
Dim lAsOf As Long
Dim iBirthMonth As Integer
Dim iAsOFMonth As Integer
If AsOf = "#1/1/1700#" Then
AsOf = DateTime.Now
End If
lDayOfBirth = DatePart(DateInterval.Day, Birthdate)
lAsOf = DatePart(DateInterval.Day, AsOf)
iBirthMonth = DatePart(DateInterval.Month, Birthdate)
iAsOFMonth = DatePart(DateInterval.Month, AsOf)
iMonths = DateDiff(DateInterval.Month, Birthdate, AsOf)
dYears = iMonths / 12
iYears = Math.Floor(dYears)
If iBirthMonth = iAsOFMonth Then
If lAsOf < lDayOfBirth Then
iYears = iYears - 1
End If
End If
Return iYears
End Function
Error:
Conversion from string "#1/1/1700#" to type 'Date' is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Conversion from string "#1/1/1700#" to type 'Date' is not valid.
Source Error:

Line 863: Dim iAsOFMonth As Integer
Line 864:
Line 865: If AsOf = "#1/1/1700#" Then
Line 866: AsOf = DateTime.Now
Line 867: End If
Thank you

Jackxxx
0
Jackxxx
11/23/2004 3:34:09 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

5 Replies
1293 Views

Similar Articles

[PageSpeed] 31
Get it on Google Play
Get it on Apple App Store

I should have used DataTime.MinValue:

if AsOf = DateTime.MinValue Then

/Fredrik Normén - fredrikn @ twitter

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog
0
Fredrik
11/23/2004 4:06:20 PM
I tried this and the error went way but the procedure outputs a negative number. 

Any Ideas?
Thanks,
Thank you

Jackxxx
0
Jackxxx
11/23/2004 6:22:16 PM
The iYears is probably 0, so then this code is executed: iYears = iYears - 1  you get -1.

Run the debugger and use the QuickWatch to see if you get the right values etc.
/Fredrik Normén - fredrikn @ twitter

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog
0
Fredrik
11/23/2004 6:28:11 PM
I have never used QuickWatch, but I output to a lable and the number was -259 if a person had a birthdate of 9/12/1958.

Any Ideas?
Thanks again,
Thank you

Jackxxx
0
Jackxxx
11/23/2004 8:16:03 PM
Add a break point to the line where you want the debugger to break and run the debugger (by pressing F5 or the start button). When the debugger reaches the break point, a yellow line will be displayed for the row where the break point was added. You can than move to he next line by pressing the F10 button, if you hold the mouse pointer over a variable, a tool tip will display the variables value. By using the debugger, you can check what is going on in your code, and also see why your code returns the wrong value.

I should really recommend you to use the debugger. It’s a great tool and can help you to see when something goes wrong etc.
/Fredrik Normén - fredrikn @ twitter

Microsoft MVP, MCSD, MCAD, MCT

ASPInsiders
My Blog
0
Fredrik
11/23/2004 8:48:32 PM
Reply:

Similar Artilces:

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Where is the ADO.NET Sybase driver for .NET 1.1 and .Net 2.0?
Hi All Does anyone know where I can get the Sybase drivers for ADO.NET for both versions, 1.1 and 2.0/3.0? Cheers Chris Burrell Hi Chris, There is no release of ASE ADO.NET Provider 2.0 (I assume you refer to ASE provider, not ASA - if ASA please port to sybase.public.sqlanywhere.general). For the 1.1 Provider: It is available in the ASE SDK for windows or the PC Client CDRom included with ASE product. On the SDK its available as 12.5.1 and 15.0 On ASE PC Client I think 12.5.1 is part of ASE 12.5.X and 15.0 is part of ASE 15.X 2.0 provider should release som...

.net 2.0 to .net 1.1
Hello , This is shrirang. Currently i am working .net2.0 web application. but the same application is runing on production in .net 1.1 freamwork . we are not using any new feature of 2.0 in our application . can i run build of 2.0 on 1.1 freamwork . if yes can you  please tell me necessary steps to achive it .     Thanks in advance for your kind help     Regards Shrirang i think it is not possible to run the 2.0 application in 1.1 , so try to change to the frame work in the production server . ThanksRaja Ragothaman Hi Shrirang, Please contact web adm...

having .net 1.1 and .net 2.0
Was just wondering if you someone could tell me the ramifications of the following:  I have .net 2.0 but did not uninstally .net 1.1, i have visual studio 2003, and visual web developer installed on the computer as well as sql server 2000.  my question is whether that is a problem having the two runtimes installed at the same time?  i did this because i wanted to use VWD but keep vs 2003 in case i needed to do any development for work....any comments are appreciated.  --jpIf my post is helpful please mark as answerRegards -- jp(http://www.rzrsolutions.com/rzrWeb20/...

Conversion of code from .net 1.1 to .net 2.0 posing a problem
Originally Posted by Akshay_Jadhav on the Microsoft Interoperability - Technical Interoperability Scenarios forumHI,I have converted .net 1.1 code to .net 2.0 using .net wizard. i have radiobutton whose checked property is set to false on page load, on clicking of a button on that page checked property of radiobutton is set to true and a dropdownlist is enabled. when i select some value in dropdownlist the page is posted back and checked property of radiobutton is again set to false(automatically) which is wrong, it should be true. Same code is working fine in .net 1.1,when i select som...

Can a page written in VB.Net 1.1 work with .Net 2.0 dlls?
Hi, Previously the Vb .Net page was working fine with GAC dll written .Net 1.1 . But the GAC dlls have been upgraded to 2.0 version and the page is thorowing error :"BC30002: Type 'CompanyUser' is not defined", where 'CompanyUser'is the class of the GAC dll. Can u help on this so that this page can be run without converting it to .Net 2.0? Thanks, SonaliThanks,Sonali  I think that you can set in IIS your page to run under 2.0. You do not have to upgrade site.__Please mark post as answer if it helps, if not come back and ask again! Hi, The only thin...

.NET 1.1 Project With File-Based Reference To A .NET 2.0 DLL Not Working
All-- Please help I have a design that requires that a given .NET 1.1 client application include a file-based reference to a DLL that was built with .NET 2.0. Unfortunately, I cannot get it to work. The VS.NET IDE will simply not let me add the reference. Ug. I have tried several tests, detailed below, but I have yet to find an answer. Can it be done? What do you think? Please advise.   ------------------------------------------------------------------------------- Overview: In in a .NET 1 project, try adding a file-based reference that points to a DLL that was created...

Upgrading from .NET 1.1 to .NET 2.0
Hi,We write ASP.NET applications for a large UK organisation for which we have two servers - a dev server and a live intranet server.  I would like to convince management to upgrade the .NET framework from 1.1 to 2.0 (and incidently VS2003 to VS2005).If we install the new version of the dotnet framework, will there be any issues with our existing 1.1 applications?  If so, what will the issues likely to be?Your help is greatly appreciated.Ryan Penfold, Truro, UK. Two versions can coexist, so you shouldn't have any issues. So far we have not had any real issues with asp.net 1.1 a...

coverting from .net 1.1 to .net 2.0
Hi All, Currently I'm facing a problem.I have an application that is built on ..net 1.1 using Vs2003.Its performance is so slow.So i want to add some partial updates to the page.How can I execute this in .net 1.1.In .net 2.0 we can use Ajaxtools, But .net 1.1 does't support ajaxtools.How to solve thgis problem.From where can I start?Please help me I'm struck in the middle.PLease forward me any sample codes You have. Thank you Hi, Why are you using VS2003. Convert your aplication in 2005/8 and use AJAX. Regards, Shahaji UThanks and Regards,Shahaji Udar.MCTS,Pune,IN...

Migration from .NET 1.1 to .NET 2.0
Hi All, Well i hoped that the migrating went smoother then is does so far. I had a few problem which i could fix with blogs from other developers, but i didn't find a good solution for this problem. Somehow i get the following error: "Make sure that the class defined in this code file matches the 'Inherits' attribute, and that it extends the correct base class" Well i worked very good before the migration. Some advise would be very welcome! Regards,Dennis van de Laarhttp://dennisv.net/Don't forget to mark the most helpful reply/replies as Answer. Maybe this post will hel...

.NET 2.0 and .NET 1.1 on the same machine
Hi All, I have .NET 2.0 and .NET 1.1 framework on my machine.  Now, I want to uninstall .NET 1.1 to have more free HD space.  Please tell if I can do it without any trouble for the .NET 2.0? Thank you very much.  Pardon me for a newbie question.  elearner Start > Control Panel > Add remove programs > remove .NET Framework 1.1! Im sure its not taking up that much space tho!? :PDavid Kiffhttp://DavidKiff.co.uk-- "Mark As Answer" If my reply helped you -- Hi, Well I don't think it should cause any problem because of them are installed in seper...

.net 2.0 v. .Net 1.1
Hi all:Im trying to figure out whether I should begin using 2.0 at this point.  Many people I spoke to have indicated that it may be too soon (for whatever reason-bugs, hosting availibility etc).  Can someone give the pros and cons at this point?  I just learned .net 1.1 and this would be the first time I've ever gone throught this sort of transition.  Also, what was frustrating about 1.1 is that some of the books that first came out had alot of problems with their code working.  Is there an authorotative book out yet with functioning examples?Any help would be ...

.NET 1.1 and .NET 2.0 on the same PC
I built my ASP.NET app and built it with .NET 1.1 I installed .Net 2.0 and now it will not function properly. How can I tell my App to use the .NET 1.1? Thanks for any help,Thank youJackxxx What tool are you using to code ASP.NET?Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). The PC i am referring to is my test PC and it has no tools. But I used VS.net 2003 on my development PC. Thank you,Thank youJackxxx Hi, Unfortunately, you can not run two...

Web resources about - Code works with .Net 1.1 but not .Net 2.0 - asp.net.getting-started

Energized Work
Fat free approach. No bureaucracy. No waste. Just common sense,disciplined technique, and radical transparency.

Financial Wisdom Works
Home Staff Privacy Policy Contact Search for: News Budgeting Education Debt Insurance Retirement Investing Credit Cards Teach Kids Financial ...

Berne Convention for the Protection of Literary and Artistic Works - Wikipedia, the free encyclopedia ...
The Berne Convention requires its signatories to recognize the copyright of works of authors from other signatory countries (known as members ...

Kenny Mayne Says Working at ESPN Beats ‘Real Work’
... part of SportsCenter on the Road at select events and will produce features for SportsCenter. “Happy to be back for more. It beats real work,” ...

Steve Ballmer says Microsoft CEO Satya Nadella's big initiative won't work
... Xbox games console and Microsoft Hololens holographic computer . So long as a device is running a version of Windows 10, the app will work. ...

Islamic State: Why West’s plan may not work
Defeating IS could be extremely difficult despite the new impetus for coalition forces to attack its territory in Syria, regional experts are ...

Bernie Kerik Tells CNN San Bernardino Attacks Could Be The Work Of Sleeper Agents
... them are making a fortune off of the security state. With his background, Kerik should never, ever be asked to go on TV for any news network. ...

Laura Ingraham Praises ‘Mr. Substance’ Sen. Jeff Sessions: He Does ‘The People’s Work’
Sessions is the 'oracle' on the TPP, the budget, refugee resettlement, and immigration

A patch for Just Cause 3's performance problems is in the works
Just Cause 3 launched this week, and blimey has it been a bit of a mess. Patrick’s review of it was positive , saying it “provides some of the ...

Male Peacock Spiders Work Hard to Win the Ladies
Female preference drives the development of ostentatious traits in males.

Resources last updated: 12/3/2015 5:13:38 PM