我是Crystal Report中的菜鸟。
我收到String length is less than 0 or not an integer
错误。
on left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)
以下代码:
local StringVar mDate;
local StringVar mMonth;
local StringVar mDay;
local StringVar mYear;
if {ORDERCHECKVIEW.LOTNUMBER} = 'N/A'
then 'N/A'
else
mDate:= left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1);
mMonth:= left(mDate,2);
mDay := Mid (mDate,4 ,2 );
mYear := totext(2010 + CDbl (right(mDate,InStr(StrReverse(left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)),"-") -1 )),0,""); // transform 2017
cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
任何人都可以解释一下有什么问题吗?我不认为我的if-else陈述是错误的。
仅供参考,我之前已经提出过一个问题,这个问题是一个后续行动: (Advanced conversion of a single number to year, along with hyphen)
答案 0 :(得分:0)
复合if-else
local StringVar mDate;
local StringVar mMonth;
local StringVar mDay;
local StringVar mYear;
if {ORDERCHECKVIEW.LOTNUMBER} = "N/A"
then "N/A"
else
(
mDate:= left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1);
mMonth:= left(mDate,2);
mDay := Mid (mDate,4 ,2 );
mYear := totext(2010 + CDbl (right(mDate,InStr(StrReverse(left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)),"-") -1 )),0,""); // transform 2017
// cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
ToText(cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay)),"MM/dd/yyyy") ;
)