vb自编程序填空题.docVIP

  • 14
  • 0
  • 约8.44千字
  • 约 8页
  • 2018-04-09 发布于湖北
  • 举报
vb自编程序填空题

程序填空题(每空2分,共20分) 编写一个字符串反转函数invert,如b=”abcde”,则invert(b)等于”edcba”。 function invert(s as string) as string dim k,slen as integer dim newstr as string newstr=”” _________ for k=slen to 1 step -1 newstr=newstr+__________ next k __________ end function 下面程序的功能是判断输入的正整数n是否为素数。 Private sub command1_click() Dim k,n as integer N=val(inputbox(“请输入正整数n”)) For k=2 to int(sqr(n)) If _________then exit for Next k If ________ then Print str(n)+”是素数” Else Print str(n)+”不是素数” End if End sub 程序的界面如图,现要求完成以下功能:1、当盘驱动器列表框drive1的当前盘符发生改变时,目录列表框dir1显示相应驱动器的目录结构;2、当双击目录列表框的某个项目时,文件列表框file1显示该项目对应文件夹中的文件。 Private sub dir1_change() ______________ End sub Private sub drive1_change() _______________ End sub 程序完成在窗体上画一条对角线(从右上角至左下角),并在窗体中心画一个半径为窗体高度四分之一的红色圆环。(该窗体的scaletop和scaleleft都为0) Private sub form_click Dim x1,y2,r as integer x1=____________ y2=form1.scaleheight r=y2/4 line (x1,0)-(0,y2) _________________________ End sub 随机生成10个10至50二位整数,并用选择法按从小到大的顺序排列。 Private sub form_click() dim a(1 to 10) as integer, k as integer dim j as integer, p as integer, n as integer for k=1 to 10 a(k)=______ next k for k=1 to 9 p=k for j=______ if a(p)a(j) then _____ next j if pk then n=a(p):a(p)=a(k):a(k)=n next k end sub 要求在窗体上以窗体中心为圆心,以窗体宽度1/4为直径画一红边实心黄圆。 Private sub form_click() Dim x as integer,r as integer Dim y as integer x=scalewidth/2 : y=scaleheight/2 r=scalewidth/4 ___________ fillcolor=rgb(255,255,0) circle ____________ End sub 下面的自定义函数delspc用来实现去除字符串中所有空格的功能。 Private function delspc(s as string) as string Dim slen as integer , n as integer Dim temps as string ,t as string * 1 Dim lstr as string , rstr as string Temps=trim(s) _________ for n=slen to 1 step -1 t=_________ If t=” ” then lstr=left(temps, n-1) rstr=mid(temps, n+1)

文档评论(0)

1亿VIP精品文档

相关文档