<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erich Allen Peterson &#187; .Net General</title>
	<atom:link href="http://www.erichpeterson.com/category/tech/net-general/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.erichpeterson.com</link>
	<description></description>
	<lastBuildDate>Wed, 01 Feb 2012 22:06:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Calculating Next Invoice Date</title>
		<link>http://www.erichpeterson.com/2007/06/calculating-next-invoice-date/</link>
		<comments>http://www.erichpeterson.com/2007/06/calculating-next-invoice-date/#comments</comments>
		<pubDate>Thu, 07 Jun 2007 19:27:59 +0000</pubDate>
		<dc:creator>Erich Peterson</dc:creator>
				<category><![CDATA[.Net General]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.erichpeterson.com/blog/tech/net-general/calculating-next-invoice-date/</guid>
		<description><![CDATA[Have you have every needed to calculate the date of the next invoice for a customer given their frequency of payment (e.g. monthly or yearly), the day of the month the first invoice was sent out (e.g. 29th, 30th, etc&#8230;), and the date of their last invoice? This can be a little complicated. For example, [...]]]></description>
			<content:encoded><![CDATA[<p>Have you have every needed to calculate the date of the next invoice for a customer given their frequency of payment (e.g. monthly or yearly), the day of the month the first invoice was sent out (e.g. 29th, 30th, etc&#8230;), and the date of their last invoice? This can be a little complicated. For example, let&#8217;s say your invoice for a customer who pays monthly, and signed up for service on the 30th of January. Well you cannot simply take their last invoice 1/30/2007 and add one month using LastInvoice.AddMonths(1) (which will give you 2/28/2007), for instance, becuase when you do the same the following month it will be 3/28/2007 instead of 3/30/2007 like it should be.</p>
<p>Other issues arise when it comes to leap years. The following code takes care of all the problems mentioned above:<br />
<br />
<strong>VB .NET</strong></p>
<pre>
Public Enum LicensePaymentType As Integer
¬† Monthly = 1
¬† Annual = 2
End Enum   

Private Function determineNextInvoice(ByVal LicType As LicensePaymentType, _
¬†         ByVal InvoiceDay As Integer, ByVal LastInvoice As DateTime) As DateTime
¬† If LicType = LicensePaymentType.Monthly Then
¬†¬†¬†¬† If LastInvoice.Day &lt; InvoiceDay Then
¬†¬†¬†¬†¬†¬†¬† Dim Temp As Integer = InvoiceDay - LastInvoice.Day
¬†¬†¬†¬†¬†¬†¬† Dim NewInvDate As DateTime = LastInvoice.AddMonths(1)
¬†¬†¬†¬†¬†¬†¬† Return NewInvDate.AddDays(Temp)
¬†¬†¬†¬† Else
¬†¬†¬†¬†¬†¬†¬† Return LastInvoice.AddMonths(1)
¬†¬†¬†¬† End If
¬† ElseIf LicType = LicensePaymentType.Annual Then
¬†¬†¬†¬† Dim NumDaysNextYearsMonth As Integer = _
           DateTime.DaysInMonth(LastInvoice.AddYears(1).Year, LastInvoice.AddYears(1).Month)
¬†¬†¬†¬† If LastInvoice.Day &lt; InvoiceDay AndAlso NumDaysNextYearsMonth &gt;= InvoiceDay Then
¬†¬†¬†¬†¬†¬†¬† Dim Temp As Integer = InvoiceDay - LastInvoice.Day
¬†¬†¬†¬†¬†¬†¬† Dim NewInvDate As DateTime = LastInvoice.AddYears(1)
¬†¬†¬†¬†¬†¬†¬† Return NewInvDate.AddDays(Temp)
¬†¬†¬†¬† Else
¬†¬†¬†¬† Return LastInvoice.AddYears(1)
¬†¬†¬†¬† End If
¬† End If
End Function</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.erichpeterson.com/2007/06/calculating-next-invoice-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Replace Those Very Stupid MS Word Curly Quotes (aka Smart Quotes)</title>
		<link>http://www.erichpeterson.com/2007/05/how-to-replace-those-very-stupid-ms-word-curly-quotes-aka-smart-quotes/</link>
		<comments>http://www.erichpeterson.com/2007/05/how-to-replace-those-very-stupid-ms-word-curly-quotes-aka-smart-quotes/#comments</comments>
		<pubDate>Wed, 23 May 2007 21:43:09 +0000</pubDate>
		<dc:creator>Erich Peterson</dc:creator>
				<category><![CDATA[.Net General]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.erichpeterson.com/blog/tech/net-general/how-to-replace-those-very-stupid-ms-word-curly-quotes-aka-smart-quotes/</guid>
		<description><![CDATA[Want to get replace those &#8220;smart quotes&#8221; that MS Word uses in your .NET code? This will do it: VB .NET Dim newstr As String newstr = oldstr.Replace(Chr(147), "&#38; quot;") ' take out extra space b/w &#38; and quot; newstr = newstr.Replace(Chr(148), "&#38; quot;") ' take out extra space b/w &#38; and quot; C# string [...]]]></description>
			<content:encoded><![CDATA[<p>Want to get replace those &#8220;smart quotes&#8221; that MS Word uses in your .NET code? This will do it:</p>
<p><strong>VB .NET</strong></p>
<pre>
Dim newstr As String
newstr = oldstr.Replace(Chr(147), "&amp; quot;") ' take out extra space b/w &amp; and quot;
newstr = newstr.Replace(Chr(148), "&amp; quot;") ' take out extra space b/w &amp; and quot;</pre>
<p><strong>C#</strong></p>
<pre>
string newstr;
newstr = oldstr.Replace((char)147, "&amp; quot;") // take out extra space b/w &amp; and quot;
newstr = newstr.Replace((char)148, "&amp; quot;") // take out extra space b/w &amp; and quot;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.erichpeterson.com/2007/05/how-to-replace-those-very-stupid-ms-word-curly-quotes-aka-smart-quotes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

