1)
过程头部这样写
procedure TWsJspj.DefaultPro(const Sel: WideString);
下面想要根据传进来的Sel值(1,2,3……)构造一个Case语句
应该怎么写?
Case Sel Of 
'1': 执行SelectA语句
'2':执行SelectB语句
else 
执行SelectC语句
End
自己这样写的总出错阿
请问正确的怎么写?
2)
StuTime1是String型,前面有赋值的一个变量:
但是下面的比较出错啊
    If ((Date()<StrToDate(StuTime1) or (Date()>StrToDate(StuTime2)) then
请问正确应该怎么写?
谢谢!

解决方案 »

  1.   

    1)
    Case Type Of 其中的 Type 指的是有序类型。
    string 类型不是有序类型,所以不被支持。2)
    var
      StuTime1, StuTime2: string;
    begin
      StuTime1 := '08-15';
      StuTime2 := '04-25';
      if (Date < StrToDate(StuTime1)) or (Date > StrToDate(StuTime2)) then
        ShowMessage('OK');
    end;
      

  2.   

    Const 定义的是一个常量
    所以那么写肯定是错误的
      

  3.   

    1、字符串之类的无顺序可分的数据是不能用在case中的。
      如果一定要这样比那就:
      if Sel='1' then ...
      else if Sel='2' then ...
      else if Sel='3' then ...
      else ...2、格式错了:
    If ((Date()<StrToDate(StuTime1)) or (Date()>StrToDate(StuTime2))) then
      

  4.   

    To: hsmserver(小霍)
    const 类型确实不能更改,但是在过程中并没有对 Sel 进行赋值,所以不是 const 的问题。
      

  5.   

    case 不支持串操作 如果你能保证值都只整型
    也可以 strtoint()
    要不就只能 一条条写IF