用VB计算1~100之间的自然数的平方和
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/13 14:36:31
Private Sub Command1_Click() Dim i As Integer &
PrivateSubCommand1_Click()DimiAsIntegerDimnAsIntegern=0Fori=1To100IfiMod3=0Thenn=n+1Printn;iEndIfNex
dimiaslongdimsumaslongsum=0fori=1to100step2sum=sum+inextiprintsum
Dim I As Integer, N As Integer &nbs
语句自己找给思路.第一种:暴力运算1.申请2个变量jsum,osum分别放奇数和、偶数和.赋初值0.2.做个循环从1到100,变量用i2.1判断i是否为奇数,是的话jsum=jsum+i,否则osum
代码如下:运行条件:form1上有一个文本框,名称text1,一个按钮,名称command1运行结果显示在text1里面PrivateSubCommand1_Click()DimiAsIntegerM
PrivateSubCommand1_Click()DimsAsString,nAsInteger,iAsIntegerFori=1To100n=n+iNextiPrint"1+2+3+……+100=
Sum=0Fori=100To300IfiMod21=0ThenSum=Sum+iEndIfNext==>优化一点:Sum=0Fori=100To300IfiMod21=0ThenSum=Sum+ii
设置了没5个换行PrivateSubBcompute_Click()t=0Fori=1To12260If(iMod3=0)And(iMod7=0)And(iMod9=0)ThenTresult.Tex
话说楼上的已经很好了,还要在做什么?算了,给你个实例吧,添加一个command按钮,输入以下代码OptionExplicitPrivateSubCommand1_Click()DimresultAsL
你好!PrivateSubForm_Click()DimiAsIntegerDimsAsIntegerFori=1To100s=s+iNextiPrintsEndSu
1填写imod6=0,指的是余数要等于0;2填写S,表示要把S输出.
PrivateSubCommand1_Click()Fori=0ToList1.ListCount-1j=j+1Ifj=11ThenExitForIfList1.List(i)NextEndSubPr
Dimsum,max,minSubaaa(ByRefsum,ByRefmax,ByRefmin)min=100'给最小值先给一个比较大的值Fori=1To100s=Int(Rnd(1)*(67-0))
Private Sub Form_Click() Dim N As Integer, e&nb
PrivateSubCommand1_Click()Dimoushu%,danshu%,sum%oushu=0danshu=0Fori=1To10Randomizesum=Int(Rnd*100)If
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e&
PrivateSubCommand1_Click()Dimi%DimsAsSingles=0Fori=1To10s=s+1/compu(i)NextiText1.Text=sEndSubFunctio
Functionfactorial(nAsInteger)AsLongDimiAsIntegerDimretAsLongret=1Fori=1Tonret=ret*iNextifactorial=re
PrivateSubCommand1_Click()Fori=iTo100IfiMod5=0OriMod7=0Thens=s+iEndIfNextiPrint"能被5或都7整除的数之和为"&sEndS