title: Converting Numbers to Excel Letter Column vb.net
body: <p>I am trying to write data to excel files using vb.net. So I my function which converts number column into excel letter columns. </p>
  
  <pre><code>Public Function ConvertToLetter(ByRef iCol As Integer) As String
  
      Dim Reminder_Part As Integer = iCol Mod 26
      Dim Integer_Part As Integer = Int(iCol / 26)
  
      If Integer_Part = 0 Then
          ConvertToLetter = Chr(Reminder_Part + 64)
      ElseIf Integer_Part &gt; 0 And Reminder_Part &lt;&gt; 0 Then
          ConvertToLetter = Chr(Integer_Part + 64) + Chr(Reminder_Part + 64)
      ElseIf Integer_Part &gt; 0 And Reminder_Part = 0 Then
          ConvertToLetter = Chr(Integer_Part * 26 + 64)
      End If
  
  
  End Function
  </code></pre>
  
  <p>The Function works ok with any other numbers. </p>
  
  <p>For example, </p>
  
  <ul>
  <li>1 => A</li>
  <li>2 => B</li>
  <li>...</li>
  <li>26 => Z</li>
  <li>27 => AA</li>
  <li>...</li>
  <li>51 => AY</li>
  <li>52 => t  (And here is when it start to went wrong) It is suppose to return AZ, but it returned t. </li>
  </ul>
  
  <p>I couldn't figure out what part I made a mistake. Can someone help me or show me how to code a proper function of converting numbers to excel letter columns using vb.net. </p>