我要取字符串skert的第二个字母k,请问该函数怎么写?

解决方案 »

  1.   

    var
      s:string;
    begin
      s:='skert';
      showmessage(s[2]);
    end;
      

  2.   

    我用在语句if copy(p_bdh, 2, 1) <> '_' then为什么编译出错?
    错误提示如下:
    operator not application to this operand type
      

  3.   

    另一种方法
    如果是变量
    var
      s: string;
    begin
      s := 'skert';
      ShowMessage(s[2]);
    end;
      

  4.   

    我用在语句if copy(p_bdh, 2, 1) <> '_' then为什么编译出错?
    错误提示如下:
    operator not application to this operand type
      

  5.   

    p_bdh必须是字符串if copy('p_bdh', 2, 1) <> '_' then这样是没有问题的
      

  6.   

    楼主:
    你的P_BDH是什么类型的? STRING吗?
      

  7.   

    用POS函数,具体资料自己找把,我用过但诗集捕住了.
      

  8.   

    var p_bdh:String;...
    p_bdh:='d_sds';
    if copy(p_bdh, 2, 1) <> '_' then
    ....
      

  9.   

    copy返回的是string,而单个字符用单引号括住Delphi好像默认为char
    要比较单个字符的话直接用p_bdh[2]<>'_'就可以了