早教吧 育儿知识 作业答案 考试题库 百科 知识分享

求几道VB题目的解答第一题运行下面程序,单击窗体后第123行分别显示什么(答案151317)dimiasinteger,sasintegerfori=1to10s=s+iifs>10thenprintss=0endifnextiendsub第二题total=0form=1to3

题目详情
求几道VB题目的解答第一题 运行下面程序,单击窗体后第123行分别显示什么(答案15 13 17) dim i as integer,s as integer for i =1 to 10 s=s+i if s>10 then print s s=0 end if next i end sub 第二题 total =0 for m= 1 to 3 if m>=1 then part=1 elseif m>=2 then part=2 elseif m>=3 then part=3 else part=4 end if print part total=total+part next m print total 运行时输出结果(答案1 1 1 3) 第三题 运行下面程序,第13行分别是(答案d dbAeB) dim mst as string,mst1 as string,mst2 as string dim i as integer mst1="CeBbAd" for i=len(mst1)to 1 step -2 mst2=mid(mst1,i-1,2) mst=mst&mst2 print mst next i end sub 第四题执行下面的command1_click 事件后,text1,text2显示内容为(答案VISUAL 2008.10.11) private sub command1_click () dim s as string,i as integer const ch as string="0123456789" s="2L0A08U.1SI0V.11" text1="" text2="" for i =1 to len(s) if instr(ch,mid(s,i,1))=0 then text1=mid(s,i,1)&text1 else text2=text2&mid(s,i,1) end if next i end sub 小弟马上要考试,辛苦打出来,求那位告诉我为什么,详细一点,拜托!
▼优质解答
答案和解析
dim i as integer,s as integer for i =1 to 10 s=s+i if s>10 then print s s=0 end if next i end sub 当s=1+2+3+4+5=15 s>10 显示15,赋予s=0 当s=6+7=13 s>10 显示13,s=0 当s=8+9=17 s>10 显示17,s=0 total =0 for m= 1 to 3 if m>=1 then part=1 elseif m>=2 then part=2 elseif m>=3 then part=3 else part=4 end if print part total=total+part next m print total i=1 part=1 total=1 显示1 i=2 part=1 total=2 显示1 i=3 part=1 total=3 显示1 循环结束 显示total,3 if语句中其实条件是包含关系,所以满足第一个条件后就结束了 所以一般分支语句的条件应该是互斥的,要不会得到错误的结果 dim mst as string,mst1 as string,mst2 as string dim i as integer mst1="CeBbAd" for i=len(mst1)to 1 step -2 mst2=mid(mst1,i-1,2) mst=mst&mst2 print mst next i end sub i的取数是6 to 1 -2,循环即为i=6,4,2 i=6 mst2=mid("CeBbAd",5,2)="Ad",mst="Ad" i=4 mst2=mid("CeBbAd",3,2)="Bd",mst="AdBd" i=2 mst2=mid("CeBbAd",1,2)="Ce",mst="AdBdCe" 我觉得答案是AdAdBbAdBbCe 错了?请高手指正吧 private sub command1_click () dim s as string,i as integer const ch as string="0123456789" s="2L0A08U.1SI0V.11" text1="" text2="" for i =1 to len(s) if instr(ch,mid(s,i,1))=0 then text1=mid(s,i,1)&text1 else text2=text2&mid(s,i,1) end if next i end sub i=1 to 16 i=1 instr(ch,mid(s,1,1))0 text2=mid(s,1,1)="2" i=2 instr(ch,mid(s,2,1))=0 text1="L" i=3 instr(ch,mid(s,3,1))0 text2="2" & mis(s,3,1)="20" i=4 instr(ch,mid(s,4,1))=0 text1=mid(s,4,1) & "L"="AL" ………… 提一下,好像const ch as string="0123456789" 里面应该包含一个小数点