vb计算1*2 2*3
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 23:00:40
PrivateSubCommand1_Click()DimsumAsDoubleDimiAsLongDimnAsDoublen=((1/(10^-5))+1)/2'正好等于10^-5时候n的值
PrivateSubCommand1_Click()DimnAsInteger,tmpAsDouble,sumAsDoubleDimiAsInteger,jAsIntegern=4tmp=1Fori=
数学计算可以简化过程:因为1-2=-1,3-4=-1...所以得出-1+(-1)+...,重复(100/2)次,即代码为(这是最简单而且最快速的办法):DimsAsInteger=-(100/2)如果
阶乘n!=n*(n-1)(n-2)(n-2)···3*2*1
PrivateSubCommand1_Click()DimsAsString,nAsInteger,iAsIntegerFori=1To100n=n+iNextiPrint"1+2+3+……+100=
PrivateSubCommand1_Click()DimSAsDouble,jcAsDouble,NAsIntegerjc=1N=Val(InputBox("请输入N"))Fori=1ToNjc=j
PrivateSubCommand1_Click()DimiAsDoubleDimnAsDoubleDimsumAsDoublesum=0IfNotIsNumeric(Text1.Text)Then'
PrivateSubfounction()DimiAsIntegerDimjAsIntegerDimkAsLongDimResAsDoubleRes=1Fori=1To10k=1Forj=iTo1St
你好!PrivateSubForm_Click()DimiAsIntegerDimsAsIntegerFori=1To100s=s+iNextiPrintsEndSu
s=1fori=1to10s=s*inextmsgboxs
PrivateSubCommand1_Click()DimnAsInteger,iAsInteger,jAsInteger,Sum&,m&n=Val(InputBox("请输入N值"))Sum=0Fo
PrivateSubCommand2_Click()DimIAsLong,SAsLongForI=1To100IfIMod2=0ThenS=S-IElseS=S+IEndIfNextPrintSEnd
PrivateSubCommand1_Click()DimiAsInteger,sAsIntegers=0Fori=1To99s=s+i*(i+1)NextiDebug.Print"计算1*2+2*3
PrivateSubCommand1_Click()DimiAsIntegerFori=1To10Sum=Sum+jc(i)NextMsgBoxSumEndSubFunctionjc(aAsInteg
dimxasinteger,dimsumasintegerforx=1to100ifxmod3=0thensum=sum+xendifnextxprintsum
PrivateSubCommand1_Click()Dimi,j,tDimsumsum=1Fori=2To10t=1Forj=1Toit=t*2Nextjsum=sum+tNextiPrintsumE
DimsumAsInteger,iAsIntegersum=0Fori=1To100sum=sum+iNextDebug.Print"1+2+...+100=";sum
PrivateSubCommand1_Click()Dimi%DimsAsSingles=0Fori=1To10s=s+1/compu(i)NextiText1.Text=sEndSubFunctio
PrivateSubCommand1_Click()DimnAsDoublen=Val(InputBox("N="))Fori=1Tons=s+1/(n*(n+1))NextiMsgBox"所求的和为
用循环句子倒是好写,就是99!估计存储不了,太大了……这个,不知道是不是要借助多个变量存储.