VB.NET 'Char' values cannot be converted to 'Integer'
<p>I have converted the C# code to VB.NET and getting following error. Is there anyway to make it work?</p>

<p>First Error</p>

<blockquote>
  <p>VB.NET 'Char' values cannot be converted to 'Integer'. Use
  'Microsoft.VisualBasic.AscW' to interpret a character as a Unicode
  value or 'Microsoft.VisualBasic.Val' to interpret it as a digit.</p>
</blockquote>

<pre><code>charValue = text(System.Math.Max(System.Threading.Interlocked.Increment(charIndex), charIndex - 1))
</code></pre>

<blockquote>
  <p>Complete Function Code</p>
</blockquote>

<pre><code>Public Shared Function embedText(text As String, bmp As Bitmap) As Bitmap
        Dim charValue As Integer = 0
charValue = text(System.Math.Max(System.Threading.Interlocked.Increment(charIndex), charIndex - 1))


                        Select Case pixelElementIndex Mod 3
                            Case 0
                                If True Then
                                    If state__1 = State.Hiding Then
                                        ' the rightmost bit in the character will be (charValue % 2)
                                        ' to put this value instead of the LSB of the pixel element
                                        ' just add it to it
                                        ' recall that the LSB of the pixel element had been cleared
                                        ' before this operation
                                        R += charValue Mod 2

                                        ' removes the added rightmost bit of the character
                                        ' such that next time we can reach the next one
                                        charValue /= 2
                                    End If
                                End If
                                Exit Select
                            Case 1
                                If True Then
                                    If state__1 = State.Hiding Then
                                        G += charValue Mod 2

                                        charValue /= 2
                                    End If
                                End If
                                Exit Select
                            Case 2
                                If True Then
                                    If state__1 = State.Hiding Then
                                        B += charValue Mod 2

                                        charValue /= 2
                                    End If

                                    bmp.SetPixel(j, i, Color.FromArgb(R, G, B))
                                End If
                                Exit Select
                        End Select

                        pixelElementIndex += 1

                        If state__1 = State.Filling_With_Zeros Then
                            ' increment the value of zeros until it is 8
                            zeros += 1
                        End If
                    Next
                Next
            Next

            Return bmp
        End Function

' convert the character value from int to char
                            Dim c As Char = CChar(charValue)
</code></pre>

<p>Second Error</p>

<blockquote>
  <p>Type Expected</p>
</blockquote>

<pre><code>Application.Run(New Project1())
</code></pre>

<p>Help me to run out of these errors.</p>