资源描述:
《常用的的测量程序vb代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、VB测量程序设计代码取一元、二元、五元的硬币共十枚,付给25元钱,有多少种不同的取法?方法一PrivateSubCommand1_Click()Print"一元","两元","五元"Fora=0To10Forb=0To10Forc=0To10Ifa+2*b+5*c=25Anda+b+c=10ThenPrinta,b,cEndIfNextcNextbNextaEndSub:方法二PrivateSubCommand1_Click()Print"一元","两元","五元"Fora=0To10Forb=0To10c=10-a-bVB测量程序设计代码Ifa+2*b+5*c=2
2、5Andc>0ThenPrinta,b,cEndIfNextbNextaEndSub九九乘法表方法一PrivateSubCommand1_Click()PrintTab(12);"九九乘法表"Fori=1To9Forj=1ToiPrinti*j;NextjPrintNextiEndSub方法二PrivateSubCommand2_Click()ShowFontSize=15PrintTab(12);VB测量程序设计代码FontSize=12PrintFork=0To9PrintTab(k*4);k;NextkjiuPrintForj=1To9Printj;Fork=1
3、TojPrintTab(k*4);j*k;NextkPrintNextjEndSub求T=8!=1×2×3×…×8PrivateSubCommand1_Click()jc=1n=Val(Text1.Text)Forc=1Tonjc=jc*cNextcPrint"jc=";jcVB测量程序设计代码EndSub用100元买100只鸡,母鸡3元1VB测量程序设计代码只,小鸡1元3只,问各应买多少只?PrivateSubCommand1_Click()DimxAsInteger,yAsIntegerForx=1To30y=100-xIf3*x+y/3=100ThenPrint
4、"母鸡只数为:";x,Print"小鸡只数为:";yEndIfNextxEndSub数组打印数组的上界和下界数值PrivateSubCommand1_Click()Dima(1To10)AsIntegerPrint"下界值","上界值"PrintLBound(a),UBound(a)EndSubVB测量程序设计代码数组解决1+2+3+4+5+6+7+8=?PrivateSubCommand1_Click()Dima(1To10)AsIntegerDimsumAsIntegerForb=1To8a(b)=bsum=sum+a(b)NextbText1.Text=sumP
5、rint"1+2+3+4+5+6+7+8="&sumEndSubVB测量程序设计代码任意五个数字之和PrivateSubCommand1_Click()DimData(5)AsIntegerDimSum,IAsIntegerForI=1To5Data(I)=InputBox("输入第"&I&"个数据")NextIForI=1To5Sum=Sum+Data(I)NextIText1.Text=SumPrintSumEndSubVB测量程序设计代码连续输入5个数字例如1,2,3,4,51+3+5+7+9=?奇数和VB测量程序设计代码PrivateSubCommand1_C
6、lick()Dima(1To5)AsIntegerDimsumAsIntegerForx=1To5a(x)=x*2-1sum=sum+a(x)NextxText1.Text=sumPrintsumEndSubPrivateFunctionpf(xAsLong,yAsLong)AsLongs=Sqr(x^2+y^2)pf=sVB测量程序设计代码EndFunctionPrivateSubCommand1_Click()DimaAsLongDimbAsLongDimcAsLonga=Val(Text1.Text)b=Val(Text2.Text)s=pf(a,b)Print
7、sEndSubSub过程和Function过程3.编写过程,求两个数的最大公约数。PrivateSubpd(xAsInteger,yAsInteger,zAsInteger)Forj=1ToyIfxModj=0AndyModj=0Thenz=jEndIfNextjEndSubPrivateSubCommand1_Click()DimaAsIntegerDimbAsIntegerVB测量程序设计代码DimcAsIntegera=Val(Text1.Text)b=Val(Text2.Text)Callpd(a,b,c)PrintcEndSub4.编写一个