<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://geeks.netindonesia.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andri Gunawan's Blog</title><link>http://geeks.netindonesia.net/blogs/andri/default.aspx</link><description>.NET Developer</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>How to get the application directory?</title><link>http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx</link><pubDate>Tue, 01 Aug 2006 20:25:00 GMT</pubDate><guid isPermaLink="false">5cc3a90d-ac9a-472a-8983-30514957434c:10475</guid><dc:creator>andri</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://geeks.netindonesia.net/blogs/andri/rsscomments.aspx?PostID=10475</wfw:commentRss><comments>http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx#comments</comments><description>&lt;P&gt;Kebetulan ngeliat di codeguru forum di link ini &lt;A href="http://www.codeguru.com/forum/showthread.php?t=312471"&gt;http://www.codeguru.com/forum/showthread.php?t=312471&lt;/A&gt; .Jadi lumayan untuk referensi.&lt;/P&gt;&lt;PRE class=alt2 style="BORDER-RIGHT: 1px inset; PADDING-RIGHT: 3px; BORDER-TOP: 1px inset; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; MARGIN: 0px; OVERFLOW: auto; BORDER-LEFT: 1px inset; WIDTH: 740px; PADDING-TOP: 3px; BORDER-BOTTOM: 1px inset; HEIGHT: 498px"&gt;&lt;FONT color=#008800&gt;// With STL string&lt;/FONT&gt;
#include &amp;lt;string&amp;gt;

&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt;        szAppPath[MAX_PATH] = &lt;FONT color=#880000&gt;""&lt;/FONT&gt;;
std::string strAppDirectory;

::GetModuleFileName(0, szAppPath, &lt;FONT color=#0000ff&gt;sizeof&lt;/FONT&gt;(szAppPath) - 1);

&lt;FONT color=#008800&gt;// Extract directory&lt;/FONT&gt;
strAppDirectory = szAppPath;
strAppDirectory = strAppDirectory.substr(0, strAppDirectory.rfind(&lt;FONT color=#880000&gt;"\\"&lt;/FONT&gt;));



&lt;FONT color=#008800&gt;// With CString&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt;    szAppPath[MAX_PATH] = &lt;FONT color=#880000&gt;""&lt;/FONT&gt;;
CString strAppDirectory;

::GetModuleFileName(0, szAppPath, &lt;FONT color=#0000ff&gt;sizeof&lt;/FONT&gt;(szAppPath) - 1);

&lt;FONT color=#008800&gt;// Extract directory&lt;/FONT&gt;
strAppDirectory = szAppPath;
strAppDirectory = strAppDirectory.Left(strAppDirectory.ReverseFind(&lt;FONT color=#880000&gt;'\\'&lt;/FONT&gt;));



&lt;FONT color=#008800&gt;// With standard string&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt; szAppPath[MAX_PATH]      = &lt;FONT color=#880000&gt;""&lt;/FONT&gt;;
&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt; szAppDirectory[MAX_PATH] = &lt;FONT color=#880000&gt;""&lt;/FONT&gt;;

::GetModuleFileName(0, szAppPath, &lt;FONT color=#0000ff&gt;sizeof&lt;/FONT&gt;(szAppPath) - 1);

&lt;FONT color=#008800&gt;// Extract directory&lt;/FONT&gt;
strncpy(szAppDirectory, szAppPath, strrchr(szAppPath, &lt;FONT color=#880000&gt;'\\'&lt;/FONT&gt;) - szAppPath);
szAppDirectory[strlen(szAppDirectory)] = &lt;FONT color=#880000&gt;'\0'&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;STRING&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post: &lt;/strong&gt;&lt;a href="mailto:?body=Thought you might like this: http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx&amp;amp;subject=How to get the application directory?" target="_blank" title="Send via email"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Mail.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.facebook.com/sharer.php?u=http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx&amp;amp;t=How+to+get+the+application+directory%3f" target="_blank" title="Submit How to get the application directory? to DotNetKicks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Facebook.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx&amp;amp;title=How+to+get+the+application+directory%3f" target="_blank" title="Submit How to get the application directory? to del.icio.us"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Delicious.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.digg.com/submit?url=http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx&amp;amp;phase=2" target="_blank" title="Submit How to get the application directory? to digg.com"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Digg.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://geeks.netindonesia.net/blogs/andri/archive/2006/08/02/10475.aspx&amp;amp;title=How+to+get+the+application+directory%3f" target="_blank" title="Add How to get the application directory? to Live Bookmarks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Live.16.gif" border="0"&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://geeks.netindonesia.net/aggbug.aspx?PostID=10475" width="1" height="1"&gt;</description><category domain="http://geeks.netindonesia.net/blogs/andri/archive/tags/C_2B002B00_+_2600_+MFC/default.aspx">C++ &amp; MFC</category></item><item><title>Fungsi Terbilang untuk C# &amp; VB.NET</title><link>http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx</link><pubDate>Fri, 09 Sep 2005 21:06:00 GMT</pubDate><guid isPermaLink="false">5cc3a90d-ac9a-472a-8983-30514957434c:7195</guid><dc:creator>andri</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://geeks.netindonesia.net/blogs/andri/rsscomments.aspx?PostID=7195</wfw:commentRss><comments>http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx#comments</comments><description>&lt;DIV&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;public static string Terbilang(int x)&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;string[] bilangan = {"", "satu", "dua", "tiga", "empat", "lima", &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 2in; TEXT-INDENT: 5.25pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;"enam", "tujuh", "delapan", "sembilan", "sepuluh", &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 2in; TEXT-INDENT: 5.25pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;"sebelas"};&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;string temp = "";&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;if (x &amp;lt; 12) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " " + bilangan[x];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 20) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x - 10).ToString() + " belas";&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 100) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 10) + " puluh" + Terbilang(x % 10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 200) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " seratus" + Terbilang(x - 100);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 1000) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 100) + " ratus" + Terbilang(x % 100);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 2000) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " seribu" + Terbilang(x - 1000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 1000000) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 1000) + " ribu" + Terbilang(x % 1000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;else if (x &amp;lt; 1000000000) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 1000000) + " juta" + Terbilang(x % 1000000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;return temp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Public Function Terbilang(ByVal x As Integer) As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Dim bilangan As String() = {"", "satu", "dua", "tiga", "empat", "lima",&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 185.25pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;"enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"} &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Dim temp As String = ""&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;If x &amp;lt; 12 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " " + bilangan(x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 20 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x - 10).ToString + " belas"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 100 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 10) + " puluh" + Terbilang(x Mod 10)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 200 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " seratus" + Terbilang(x - 100)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 1000 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 100) + " ratus" + Terbilang(x Mod 100)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 2000 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = " seribu" + Terbilang(x - 1000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 1000000 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 1000) + " ribu" + Terbilang(x Mod 1000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Else If x &amp;lt; 1000000000 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;temp = Terbilang(x / 1000000) + " juta" + Terbilang(x Mod 1000000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;Return temp&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;End Function&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post: &lt;/strong&gt;&lt;a href="mailto:?body=Thought you might like this: http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx&amp;amp;subject=Fungsi Terbilang untuk C# &amp; VB.NET" target="_blank" title="Send via email"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Mail.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.facebook.com/sharer.php?u=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx&amp;amp;t=Fungsi+Terbilang+untuk+C%23+%26+VB.NET" target="_blank" title="Submit Fungsi Terbilang untuk C# &amp; VB.NET to DotNetKicks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Facebook.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx&amp;amp;title=Fungsi+Terbilang+untuk+C%23+%26+VB.NET" target="_blank" title="Submit Fungsi Terbilang untuk C# &amp; VB.NET to del.icio.us"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Delicious.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.digg.com/submit?url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx&amp;amp;phase=2" target="_blank" title="Submit Fungsi Terbilang untuk C# &amp; VB.NET to digg.com"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Digg.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7195.aspx&amp;amp;title=Fungsi+Terbilang+untuk+C%23+%26+VB.NET" target="_blank" title="Add Fungsi Terbilang untuk C# &amp; VB.NET to Live Bookmarks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Live.16.gif" border="0"&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://geeks.netindonesia.net/aggbug.aspx?PostID=7195" width="1" height="1"&gt;</description><category domain="http://geeks.netindonesia.net/blogs/andri/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://geeks.netindonesia.net/blogs/andri/archive/tags/VB.NET/default.aspx">VB.NET</category></item><item><title>Unsafe programming in C#</title><link>http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx</link><pubDate>Fri, 09 Sep 2005 20:49:00 GMT</pubDate><guid isPermaLink="false">5cc3a90d-ac9a-472a-8983-30514957434c:7193</guid><dc:creator>andri</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://geeks.netindonesia.net/blogs/andri/rsscomments.aspx?PostID=7193</wfw:commentRss><comments>http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx#comments</comments><description>&lt;DIV&gt;&lt;!--StartFragment --&gt;&lt;!--StartFragment --&gt;&lt;STRONG&gt;By &lt;/STRONG&gt;Kumar Gaurav Khanna&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://www.codeproject.com/csharp/unsafe_prog.asp"&gt;http://www.codeproject.com/csharp/unsafe_prog.asp&lt;/A&gt;&lt;BR&gt;&lt;/DIV&gt;
&lt;H2&gt;Introduction&lt;/H2&gt;
&lt;P&gt;There's always one particular topic that catches the fancy of most C/C++ programmers, and is considered quite complicated and difficult to understand: &amp;nbsp; pointers!&lt;/P&gt;
&lt;P&gt;Albeit, whenever C# is discussed, most of the people I have come across are of the opinion (and pretty strong one, if I may add) that C# carries no concept of pointers. In fact, it's done away with it. However, unsafe code is that part of C# programming, which is all about programming with pointers. Unlike it's literal meaning, there is nothing unsafe about programming with pointers.&lt;/P&gt;
&lt;P&gt;The reason it is so referred to as is because, unlike the conventional .NET development that is done, unsafe programming requires certain assumptions on the part of the programmer. In this article, I shall start off by differentiating two highly confused terms, unsafe code and unmanaged code. This will be followed by discussion of how to write unsafe code, that is, how to use pointers in C#.&lt;/P&gt;
&lt;H2&gt;Unsafe or unmanaged? That is the question&lt;/H2&gt;
&lt;P&gt;Managed code is that code which executes under the supervision of the CLR. The CLR is responsible for various housekeeping tasks, like:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;managing memory for the objects&lt;/LI&gt;
&lt;LI&gt;performing type verification&lt;/LI&gt;
&lt;LI&gt;doing garbage collection&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;just to name a few. The user is totally isolated from the how's of the above mentioned tasks. The user doesn't get to manipulate the memory directly, because that is done by the CLR. &lt;/P&gt;
&lt;P&gt;On the other hand, unmanaged code is that code which executes outside the context of the CLR. The best example of this is our traditional Win32 DLLs like &lt;I&gt;kernel32.dll&lt;/I&gt;, &lt;I&gt;user32.dll&lt;/I&gt;, and the COM components installed on our system. How they allocate memory for their usage, how memory is released, how (if any) type verification takes places are some of the tasks that are undertaken by them on their own. A typical C++ program which allocates memory to a character pointer is another example of unmanaged code because you as the programmer are responsible for:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;calling the memory allocation function&lt;/LI&gt;
&lt;LI&gt;making sure that the casting is done right&lt;/LI&gt;
&lt;LI&gt;making sure that the memory is released when the work is done&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you notice, all this housekeeping is done by the CLR, as explained above, relieving the programmer of the burden.&lt;/P&gt;
&lt;H3&gt;Unsafe code is a kind of cross between the managed and unmanaged codes&lt;/H3&gt;
&lt;P&gt;It executes under the supervision of the CLR, just like the managed code, but lets you address the memory directly, through the use of pointers, as is done in unmanaged code. Thus, you get the best of both worlds. You might be writing a .NET application that uses the functionality in a legacy Win32 DLL, whose exported functions require the use of pointers. That's where unsafe code comes to your rescue.&lt;/P&gt;
&lt;P&gt;Now that we have gone through the distinctions, let's get coding... unarguably the best part, what do you think?&lt;/P&gt;
&lt;H2&gt;Inside unsafe code&lt;/H2&gt;
&lt;P&gt;Writing unsafe code requires the use of two special keywords: &lt;CODE&gt;unsafe&lt;/CODE&gt; and &lt;CODE&gt;fixed&lt;/CODE&gt;. If we recall, there are three kinds of pointer operators:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;*&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;&amp;amp;&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;-&amp;gt;&lt;/CODE&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Any statement, or a block of code, or a function that uses any of the above pointer operators is marked as unsafe through the use of the &lt;CODE&gt;unsafe&lt;/CODE&gt; keyword, as shown below:&lt;/P&gt;&lt;PRE lang=cs&gt;&lt;SPAN class=cs-keyword&gt;public&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;unsafe&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;void&lt;/SPAN&gt; Triple(&lt;SPAN class=cs-keyword&gt;int&lt;/SPAN&gt; *pInt)
{
  *pInt=(*pInt)*&lt;SPAN class=cs-literal&gt;3&lt;/SPAN&gt;;
}&lt;/PRE&gt;
&lt;P&gt;All the above function does is triple the value passed to it. But notice that the address of the variable, containing the value to be tripled, is passed to the function. The function then does its work. Since the function is using the "*" pointer operator, the function is marked as unsafe, since the memory is being directly manipulated. &lt;/P&gt;
&lt;P&gt;However, there is a problem. If you recall from the discussion above, unsafe code is managed code, and hence, is being executed under the CLR's supervision. Now, the CLR is free to move the objects in memory. One plausible reason could be to reduce the memory fragmentation. But in doing so, unknowingly and transparently to the programmer, the variable being pointed to could be get relocated to some other memory locations.&lt;/P&gt;
&lt;P&gt;So, if &lt;CODE&gt;*pInt&lt;/CODE&gt; pointed to a variable which was at address 1001, and the CLR performs some memory relocation to reduce fragmentation, the variable which was earlier located at 1001 could, after relocation, be stored at memory location 2003. This is a catastrophe, since the pointer becomes invalid as there is nothing at memory location 1001 after relocation! Probably that's one of the reason usage of pointers has been made to keep a low profile in .NET. What do you think?&lt;/P&gt;
&lt;H2&gt;Fixing the pointers&lt;/H2&gt;
&lt;P&gt;Enter the &lt;CODE&gt;fixed&lt;/CODE&gt; keyword. When used for a block of statements, it tells the CLR that the object in question cannot be relocated, and thus, it ends up pinning the object. Thus, when pointers are used in C#, the &lt;CODE&gt;fixed&lt;/CODE&gt; keyword is used pretty often to prevent invalid pointers at runtime. Lets have a look at how it works:&lt;/P&gt;&lt;PRE lang=cs&gt;&lt;SPAN class=cs-keyword&gt;using&lt;/SPAN&gt; System;
&lt;SPAN class=cs-keyword&gt;class&lt;/SPAN&gt; CData
{
    &lt;SPAN class=cs-keyword&gt;public&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;int&lt;/SPAN&gt; x;
}

&lt;SPAN class=cs-keyword&gt;class&lt;/SPAN&gt; CProgram
{
    &lt;SPAN class=cs-keyword&gt;unsafe&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;static&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;void&lt;/SPAN&gt; SetVal(&lt;SPAN class=cs-keyword&gt;int&lt;/SPAN&gt; *pInt)
    {
        *pInt=&lt;SPAN class=cs-literal&gt;1979&lt;/SPAN&gt;;
    }
    
    &lt;SPAN class=cs-keyword&gt;public&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;unsafe&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;static&lt;/SPAN&gt; &lt;SPAN class=cs-keyword&gt;void&lt;/SPAN&gt; Main()
    {
        CData d = &lt;SPAN class=cs-keyword&gt;new&lt;/SPAN&gt; CData();
        
        Console.WriteLine(&lt;SPAN class=cpp-string&gt;"Previous value: {0}"&lt;/SPAN&gt;, d.x);
        
        &lt;SPAN class=cs-keyword&gt;fixed&lt;/SPAN&gt;(&lt;SPAN class=cs-keyword&gt;int&lt;/SPAN&gt; *p=&amp;amp;d.x)
        {
            SetVal(p);
        }
        
        Console.WriteLine(&lt;SPAN class=cpp-string&gt;"New value: {0}"&lt;/SPAN&gt;, d.x);
    }
}&lt;/PRE&gt;
&lt;P&gt;All we do here is assign the address of field &lt;CODE&gt;x&lt;/CODE&gt; of class &lt;CODE&gt;CData&lt;/CODE&gt; to integer pointer &lt;CODE&gt;p&lt;/CODE&gt;, within the fixed block. Now, while statements within the fixed block are executing, the pointer shall continue to point to the same memory location because the CLR has been instructed to pin the variable until the fixed block execution finishes. Once the fixed block is done, the object can be relocated in memory by the CLR.&lt;/P&gt;
&lt;P&gt;That's all there is to programming using pointers in C#. Just make sure that the block is &lt;CODE&gt;unsafe&lt;/CODE&gt; and that the object being pointed to is &lt;CODE&gt;fixed&lt;/CODE&gt;. And you are ready to leverage your knowledge of pointers in C# too!&lt;/P&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post: &lt;/strong&gt;&lt;a href="mailto:?body=Thought you might like this: http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx&amp;amp;subject=Unsafe programming in C#" target="_blank" title="Send via email"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Mail.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.facebook.com/sharer.php?u=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx&amp;amp;t=Unsafe+programming+in+C%23" target="_blank" title="Submit Unsafe programming in C# to DotNetKicks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Facebook.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx&amp;amp;title=Unsafe+programming+in+C%23" target="_blank" title="Submit Unsafe programming in C# to del.icio.us"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Delicious.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="http://www.digg.com/submit?url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx&amp;amp;phase=2" target="_blank" title="Submit Unsafe programming in C# to digg.com"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Digg.16.gif" border="0"&gt;&lt;/a&gt; | &lt;a href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://geeks.netindonesia.net/blogs/andri/archive/2005/09/10/7193.aspx&amp;amp;title=Unsafe+programming+in+C%23" target="_blank" title="Add Unsafe programming in C# to Live Bookmarks"&gt;&lt;img src="http://geeks.netindonesia.net/Images/Share.Live.16.gif" border="0"&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://geeks.netindonesia.net/aggbug.aspx?PostID=7193" width="1" height="1"&gt;</description><category domain="http://geeks.netindonesia.net/blogs/andri/archive/tags/C_2300_/default.aspx">C#</category></item></channel></rss>
