long   length_string,step_string,asc_char,i 
                string   pym_string,pym,char_string 
                //   取得字符串长度   
                length_string   =   len(hz_cluster) 
                  //   设定初始值 
                  i   =   1 
                  pym_string   =   ' ' 
                  do   until   i   >   length_string 
char_string   =   mid(hz_cluster,i,1) 
asc_char   =   asc(char_string) 
//   设定默认步长 
step_string   =   1 
if   asc_char   >   64   and   asc_char   <   91   then                         //   大写字母 
pym   =   char_string 
elseif   asc_char   >   96   and   asc_char   <   123   then               //   小写字母 
pym   =   char_string 
elseif   asc_char   >   47   and   asc_char   <   58   then                 //   数字 
pym   =   char_string 
elseif   asc_char   >   127   then                                                   //   汉字,步长为2 
char_string   =   mid(hz_cluster,i,2) 
select   pym   into   :pym   from   sys_hzk   where   hz=:char_string; 
If   Sqlca.sqlcode   <>   0   Then   pym   =   '* ' 
pym   =   mid(pym,1,1) 
step_string   =   2 
else                                                                                               //   其它字符 
pym   =   ' ' 
end   if 
i   =   i   +   step_string 
pym_string   =   pym_string   +   pym 
                    loop 
                  //   以小写方式返回 
                    return   left(upper(pym_string),12) 
 

解决方案 »

  1.   

    mid -> sustring
    asc -> convert.toint32left -> sustring其他的不用说了吧,就这么几个方法在里面
      

  2.   

    google+baidu+msdn,自己花时间学到知识才能记忆深刻。
      

  3.   

    用在线 VB 转 C# 的:
    http://codechanger.com/
      

  4.   

            public static string getPYM(string hz_cluster)
            {
                int length_string = 0; 
                string pym_string = string.Empty, pym = string.Empty;
                char char_string = ' ';
                //   取得字符串长度  
                length_string = hz_cluster.Length;
                //   设定初始值
                int i = 0;
                int asc_char;
                while (i < length_string)
                {
                    char_string = hz_cluster.Substring(i, 1)[0];
                    asc_char = Convert.ToInt32(char_string);
                    if ((asc_char > 64) && (asc_char < 91))//   大写字母
                    {
                        pym = char_string.ToString();
                    }
                    else if ((asc_char > 96) && (asc_char < 123))              //   小写字母
                    {
                        pym = char_string.ToString();
                    }
                    else if ((asc_char > 47) && (asc_char < 58))              //   数字
                    {
                        pym = char_string.ToString();
                    }
                    else if (asc_char > 127)                             //   汉字
                    {
                        pym = GetOnePYM(hz_cluster.Substring(i, 1));
                    }
                    else
                    {//   其它字符
                        pym = "*";
                    }
                    i += 1;
                    pym_string = pym_string + pym;
                }
                //   以大写方式返回
                return pym_string.ToUpper();
            }
            public static string GetOnePYM(string hz)
            {
                return DBHelper.ExecuteScalar("select isnull(pym,'*') from sys_hzk where hz=@hz"
                                   , new SqlParameter[] { new SqlParameter("@hz", hz) }).ToString();
            }
      

  5.   


    结贴了,这是最终测试过的code..