资源描述:
《新疆医科大学 选修课考试答案vb》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、1.圆的周长PrivateSubCommand1_Click()Dimr!,s!,c!,pi!pi=3.14r=Val(Text1)c=2*pi*rText2=Format(c,"0.00")EndSubu圆的面积PrivateSubCommand2_Click()Dimr!,s!,c!,pi!pi=3.14r=Val(Text3)s=pi*r*rText3=Format(s,"0.00")EndSubu随机产生[1,35]之间的7个整数PrivateSubCommand1_Click()Dimi!Fori=1To7PrintInt(Rnd*35+1
2、);NextiPrintEndSub3.编写一个华氏温度与摄氏温度之间转换的程序。界面如图3。C=5/9*(F-32)(C是摄氏温度)PrivateSubCommand1_Click()Dimf!,c!f=Text1c=5/9*(f-32)Text2=Format(c,"0.00")EndSubPrivateSubCommand2_Click()Dimf!,c!c=Text2f=9/5*c-32Text1=Format(f,"0.00")EndSub4.超市团购问题PrivateSubCommand1_Click()Dimy!,x!x=Val(Tex
3、t1)Ifx>=2Theny=x*0.7ElseIfx>=1Theny=x*0.8ElseIfx>=0.2Theny=x*0.9Elsey=xEndIfText2=Format(y,"0.00")EndSub5.人口增长问题PrivateSubCommand1_Click()Dimn%,y!y=13.3n=0DoWhiley<=26y=y*1.0028n=n+1LoopText1=nEndSub6.求从1到300能被17整除的所有数的和PrivateSubCommand1_Click()Dimi%,s%s=0Fori=1To300IfiMod17=0
4、ThenSum=i+1EndIfNextiText1=SumEndSub7.用PictureBox控件(要求图形框随图形大小变)和通用对话框(使用打开设置),打开图片文件。界面如图PrivateSubCommand1_Click()CommonDialog1.Action=1Picture1.Picture=LoadPicture(CommonDialog1.FileName)EndSub注意:autosize为true8.小球经过的路程为多少?界面如图8。PrivateSubCommand1_Click()Dims!,h!,i%Sum=1h=1Fo
5、ri=1To9h=1/2*hSum=Sum+2*hNextiText1=SumEndSub9.使用ImageBox控件,打开一个图片文件(图片的位置:D:BFLY.bmp,并要求图像框大小不变),然后删除该图片PrivateSubCommand1_Click()Image1.Picture=LoadPicture("d:bfly*bmp")EndSubPrivateSubCommand2_Click()Image1.Picture=LoadPicture()EndSub10.使用通用对话框改变标签标题的颜色(注:label1的标题为新疆医科大学,
6、居中,字体设置为24磅)。界面如图10PrivateSubCommand1_Click()CommonDialog1.Action=3Label1.ForeColor=CommonDialog1.ColorEndSub11.制作一个调色板。界面如图11Dimr%,g%,b%PrivateSubCommand1_Click()Text2.BackColor=Text1.BackColorEndSubPrivateSubCommand2_Click()Text2.ForeColor=Text1.BackColorEndSubPrivateSubHScro
7、ll1_Change()r=HScroll1.ValueText1.BackColor=RGB(r,g,b)EndSubPrivateSubHScroll2_Change()g=HScroll2.ValueText1.BackColor=RGB(r,g,b)EndSubPrivateSubHScroll3_Change()b=HScroll3.ValueText1.BackColor=RGB(r,g,b)EndSub12.一维数组的使用,用inputbox函数输入10个学生的成绩放在数组score(1to10),要求计算平均分。界面如图12Priva
8、teSubCommand1_Click()Dimscore(1To10)Dimi%,sum%Fori=1To