莱斯南京什么意思:VB程序问题:高手快进

来源:百度文库 编辑:高校问答 时间:2024/05/02 07:44:55
sub area()
dim lenth ,width as integer
do
if lenth<>0 and width<>0 then area=lenth*width
end if
end do
end sub
(请问错在哪?)

sub area()
dim lenth ,width as integer
if lenth<>0 and width<>0 then area=lenth*width
end sub

sub area()
dim lenth as integer '最好就是用这种方法声明变量
dim width as integer
do while '这是一个do while..loop 的语句

if lenth<>0 and width<>0 then area=lenth*width '上面说了这里没有转行
'所以不用end if

exit do '退出do while 循环应使用Exit do 不是End do

loop

end sub

if lenth<>0 and width<>0 then area=lenth*width
end if
不对if语句如果就一行就不需要end if,而且vb里判不等似乎是“!=”
这样试一试
if lenth!=0 and width!=0 then area=lenth*width