Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have 1 project in c# i am converted it into vb.net but i got some difficulty in it some part of code which is properly worked in C# but if we convert into VB.net then it gives error i give you both codes if possible then give me the right code please....

C#
C#
static string GetCoreSound(string str, ref int totalCoreSoundCharacter)
        {
            string soundmap = "अबसदइफगहईजकलमनओपकरसतउववज़यज";
            string h_shift = GethShift(str,ref totalCoreSoundCharacter);
            if (h_shift == null)
            {
               int position = ((str[0]) - 'a');
                if (position < soundmap.Length && position >= 0)
                {
                    return "" + soundmap[position];
                }
                totalCoreSoundCharacter=1;
                return str;

            }
            else
            {
                return h_shift;
            }
        }


VB.net
VB
Private Shared Function GetCoreSound(ByVal str As String, ByRef totalCoreSoundCharacter As Integer) As String
            Dim soundmap As String = "अबसदइफगहईजकलमनओपकरसतउववज़यज"
            Dim h_shift As String = GethShift(str, totalCoreSoundCharacter)
            If h_shift Is Nothing Then
                Dim position As Integer = ((str(0)) - "a"c)
                If position < soundmap.Length AndAlso position >= 0 Then
                    Return "" & soundmap(position)
                End If
                totalCoreSoundCharacter = 1

                Return str
            Else
                Return h_shift
            End If
        End Function

**************************************************
where the code is bold there is problem....
" Dim position As Integer = ((str(0)) - "a"c)"
this line is not working so please tell me proper..
--
With Regards

Apeksha Deshpande
Posted
Updated 24-May-11 22:44pm
v2
Comments
Sandeep Mewara 25-May-11 4:47am    
If you add what you are trying to do here then it would help:

int position = ((str[0]) - 'a');

subtracting ASCII of 'a' from the string? What does str[0] contains]?
apeksha4deshpande 25-May-11 4:52am    
this is code for onverting english into hindi
in str[0]
if we type abc then str[0]="a"

1 solution

update the problem line with below

Dim position As Integer = Convert.ToInt32(s(0)) -  Convert.ToInt32("a"c)


Hope it will help
--hemant
 
Share this answer
 
Comments
apeksha4deshpande 25-May-11 4:56am    
thanks
Hemant__Sharma 25-May-11 4:58am    
you are welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900