vb 编程 计算100~300之间所有能被3和7整除的数有哪些,并有几个,求代码

如题所述

Dim i As Integer
Dim n As Integer
For i = 100 To 300
If (i Mod 3 = 0) And (i Mod 7 = 0) Then
n = n + 1
Print i
End If
Next
Print "能被二者同时整除的数共有" & n & "个。"
温馨提示:内容为网友见解,仅供参考
无其他回答

vb程序设计单击窗体,求200到300之间既能被3整除又能被7整除的数
Private Sub Form_Click()Dim i As Integer For i = 200 To 300 If (i Mod 3 = 0) And (i Mod 7 = 0) Then Print i Next i End Sub

用vb求出100到900能同时被3,5,7整除的数,并求和的代码
Private Sub Form_Click() '点击窗体开始运行Dim s As Long, x As LongMe.ClsPrint "100到900能同时被3,5,7整除的数有:"For x = 100 To 900 If x Mod 3 = 0 And x Mod 5 = 0 And x Mod 7 = 0 Then Print x; s = s + x End IfNextPrintPrint "它们的和是...

VB.求出0~100的整数能够被3整除的个数以及能够被7整除的个数。程序...
dim sum as integer'和 dim count as integer'个数 sum=0 count=0 text3.text=""For i=1 to 100 If i Mod 3=0 And i Mod 7<>0 Then count=count+1 sum=sum+i text3.text=text3.text & i'text3显示都有什么数 End If Next text1.text="和为:"+ sum text2.text="个数为:...

vb题,求200以内能被3和能被7整除的个数
Private Sub Command1_Click() MsgBox ("200以内能同时被3和7整除的个数: " & 200 \\ 21 & vbCrLf & "能被3或7整除的个数:" & 200 \\ 3 + 200 \\ 7 - 200 \\ 21)End Sub

VB 输出同时能被3和7整除的数
Mod 运算符,用来对两个数作除法并且只返回余数。And 运算符,用来对两个表达式进行逻辑连接。假设某数是i:i Mod 3 = 0 And i Mod 7 = 0 Dim i As Long For i = 1 To 1000 If i Mod 3 = 0 And i Mod 7 = 0 Then Print i Next ...

vb程序设计 0到1000中能被7整除数字的个数
回答:Private Sub Command1_Click() Dim i As Integer, j As Integer For i = 1 To 1000 If i Mod 7 = 0 Then j = j + 1 Next Print j End Sub

求1到100之间能被3整除且能被7整除的数的和的vb编辑
sub command1_click()dim i as integer, s as integer s = 0 for i = 1 to 100 if (i mod 3 = 0 and i mod 7 = 0) then s = s + i next msgbox s end sub

vb程序找出1到1999之间同时被3和7整除的,个位数3的数,同时统计其...
Private Sub Command1_Click()Dim A(1 To 200) As Integer, X As IntegerFor I = 1 To 1999 If I Mod 3 = 0 And I Mod 7 = 0 Then X = X + 1 A(X) = I End IfNext IText1.Text = XFor I = 1 To X If I < X Then Text2.Text = Text2.Text &...

VB编程求1到1000中能被3整除的数的个数
dim num3,num7 as integer for i=1 to 1000 if i mod 3=0 then num3=num3+1 end if if i mod 7=0 then num7=num7+1 end if next 最后num3就是能被3整除的数的个数。num7是能被7整除的个数。

vb题答案!(内部)
1.编程在窗体上输出101~500之间的所有能被3或者7整除的奇数,按照一行5个的方式输出并最后符合要求的数的和。解:代码为 Private Sub form_load()Show Dim n, sum As Integer Print Spc(6); "101~500之间的所有能被3或者7整除的奇数,及各数的和"i = 0 sum = 0 For n = 101 To 500 ...

相似回答