dkfr.net
当前位置:首页 >> vB循环结构中出入初始值,输出100个不能被3整除的数... >>

vB循环结构中出入初始值,输出100个不能被3整除的数...

Sub s() i% = InputBox("输入初始值:") Do While c < 100 If i Mod 3 0 Then c = c + 1: Debug.Print i; i = i + 1 If c Mod 10 = 0 Then Debug.Print LoopEnd Sub

dim i as long dim k as long i=0 k=0 do while i< 100 k = k+1 if (k mod 3) 0 then '被3整除 debug.print k i = i +1 end if loop

这100个数是顺序的吗? 如下: Private Sub Command1_Click() n = Val(InputBox("请输入一个数")) t = 0 For i = n To 100000 If i Mod 3 0 Then Print i; t = t + 1 End If If t = 100 Then Exit For If t Mod 10 = 0 Then Print Next End Sub...

只给你一段代码吧。这个用任意循环语句+选择语句都可以实现 dim a as integer ‘定义一个整形变量a a=0 'a是用来分行的,这里是用来打印的,如果不分行,显示结果会很难看,所以加了个a,楼主也可以去掉 for i= 1 to 100 ’执行100次循环,也就是...

Private Sub Form_Click() For i = 1 To 100 If i Mod 3 0 Then Print i Next iEnd Sub

Private Sub Command1_Click() a = 100 While a

好的,就做这道练习题(添加一个命令按钮) Private Sub Command1_Click() Dim i As Integer, n As Integer, s As Integer For i = 1 To 100 If i Mod 3 = 0 Then n = n + 1 s = s + i End If Next i Print "1~100自然数中能被3整除的数据的个数为...

Private Sub Form_Click() '单击窗体时执行下面代码 Dim i As Integer, row As Integer '定义i、row为整形变量 Cls '清除窗体上原来的文字 Print "100-200之间不能被3整除的数有:" '在窗体上大印出引号内的文字 Print '空一行 Print '空一行 ro...

Dim str As String = "" Dim n As Integer n = 0 For i = 100 To 200 If i Mod 3 0 Then str = str & i & " " n = n + 1 If n Mod 6 = 0 Then str = str & vbCrLf End If End If Next TextBox2.Text = str 运行结果 100 101 103 104 106 107 10...

Private Sub Form_Click() Dim i As Integer, sum As Integer sum = 0 For i = 100 To 200 If ((i Mod 2) = 1) And ((i Mod 3) 0) Then Print i sum = sum + i End If Next i Print sum End Sub

网站首页 | 网站地图
All rights reserved Powered by www.dkfr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com