vb实验中将1-50之间能被3和5整除的数相加,当累积和超过30时,显示累加和.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/12 04:25:44
subcommand1_click()dimiasinteger,sasintegers=0fori=1to100if(imod3=0andimod7=0)thens=s+inextmsgboxsen
求奇偶数:Fori=1to100Ifi/2i\2Thenmsg=msg&i&"是奇数"Elsemsg=msg&i&"是偶数"NextiPrintmsg能被3和5同时整除:Fori=1to100Ifi/
privatesubcommand1_click()dimsumasintegerdimiasintegersum=0fori=1to50ifimod3=0thenmsgboxi&"能被3整除",Vb
dimnum3asintegerfori=1to1000ifimod3=0thennum3=num3+iendifnext
3再答:6再答:9再答:12再答:12再答:15再答:18再答:21再答:24再答:27再答:30再答:33再答:36再答:39再答:42再答:45再答:48再答:51再答:54再答:57再答:60再
SubMain()MsgBoxFunc(100,2,5)'按照要求写的例子EndSubRem参数(最大值,被整除的数的数组)FunctionFunc(n&,ParamArrayx())Dimi&,b&
RANDOM(1,30)
代码如下:运行条件:form1上有一个文本框,名称text1,一个按钮,名称command1运行结果显示在text1里面PrivateSubCommand1_Click()DimiAsIntegerM
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
PrivateSubForm_Click()Dimx1%,x2%,count%count=0Fori=1To100x1=iMod5x2=iMod7Ifx1=0Andx2=0ThenPrinti;End
1填写imod6=0,指的是余数要等于0;2填写S,表示要把S输出.
'单击窗体函数里面的代码:DimiAsInteger'从1~200DimcountAsInteger'保存所求的和Fori=1to200If(iMod5=0)And(iMod7=0)Thencount
Dim i, j j = 0 &
dimiasintegerdimsumasintegersum=0fori=100to200step5ifimod30thensum=sum+inext
PrivateSubCommand1_Click()Fori=1To100IfiMod7=0Thenn=n+1EndIfNextiPrintnEndSu
在窗体上添加三个文本框,和一个按钮.在按钮的单击事件中写:privatesubcommand1_clickdimsumasinteger'和dimcountasinteger'个数sum=0count
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e&
Fori=100To999IfiMod10=3AndiMod7=0ThenPrintiEndIfNexti
dimsum%,i%fori=1to40ifimod5=0thensum=sum+inextprintsum再问:mod什么意思啊没怎么听课不懂啊谢谢啊