以下是引用kiff在2014-12-10 15:24:54的发言:
x=int(thisform.text1.value) &&thisform.text1.value 你本设它为数值型了,不需要再用 val()转换
*InLen=len(alltrim(padl(x,20," "))) &&alltrim()和 padl()不是有矛盾吗
InLen=len(padl(x,20," ")) &&注意" "中是有一个空格的
y1=int(x/100)
x=x-100*y1
y2=int(x/50)
x=x-50*y2
y3=int(x/20)
x=x-20*y3
y4=int(x/10)
x=x-10*y4
y5=int(x/5)
x=x-5*y5
y6=int(x/2)
x=x-2*y6
y7=x
a="==========="+chr(13)
a=a + padl(y1,InLen," ")+"张100元票"+padl(y2,InLen," ")+"张50元票"+chr(13)
a=a + padl(y3,InLen," ")+"张20元票"+padl(y4,InLen," ")+"张10元票"+chr(13)
a=a + padl(y5,InLen," ")+"张5元票"+padl(y6,InLen," ")+"张2元票"+chr(13)
a=a + padl(y7,InLen," ")+"张1元票"+chr(13)
a=a+"========="+chr(13)
a=a+"共计"+TRANSFORM(thisform.text1.value)+"元"
messagebox(a,0,"取款")
thisform.text1.setfocus
x=int(thisform.text1.value) &&thisform.text1.value 你本设它为数值型了,不需要再用 val()转换
*InLen=len(alltrim(padl(x,20," "))) &&alltrim()和 padl()不是有矛盾吗
InLen=len(padl(x,20," ")) &&注意" "中是有一个空格的
y1=int(x/100)
x=x-100*y1
y2=int(x/50)
x=x-50*y2
y3=int(x/20)
x=x-20*y3
y4=int(x/10)
x=x-10*y4
y5=int(x/5)
x=x-5*y5
y6=int(x/2)
x=x-2*y6
y7=x
a="==========="+chr(13)
a=a + padl(y1,InLen," ")+"张100元票"+padl(y2,InLen," ")+"张50元票"+chr(13)
a=a + padl(y3,InLen," ")+"张20元票"+padl(y4,InLen," ")+"张10元票"+chr(13)
a=a + padl(y5,InLen," ")+"张5元票"+padl(y6,InLen," ")+"张2元票"+chr(13)
a=a + padl(y7,InLen," ")+"张1元票"+chr(13)
a=a+"========="+chr(13)
a=a+"共计"+TRANSFORM(thisform.text1.value)+"元"
messagebox(a,0,"取款")
thisform.text1.setfocus
InLen=len(alltrim(padl(x,20," ")))
加AllTrim()的用意可知道?
AllTrim()与Padl()有何矛盾
这个地方是计算输入数据的实际长度,如果不用AllTrim(),输入任何数据,其长度必将是20位。
坚守VFP最后的阵地