編寫vb程式,輸出100 200之間不能被3整除的數

2021-12-20 14:29:55 字數 3865 閱讀 8594

1樓:匿名使用者

option explicitprivate sub command1_click()

dim i as integer, n as integeri = 100

while i <= 200

if i mod 3 = 0 then

print i;

n = n + 1

if n mod 10 = 0 then print '十個數換一行end if

i = i + 1

wendend sub

2樓:匿名使用者

private sub form_click()dim i as integer, n as integeri = 100

do while i <= 200

if i mod 3 = 0 then

print i;

n = n + 1

if n mod 10 = 0 then printend if

i = i + 1

loop

end sub

3樓:匿名使用者

private sub command1_click()a = 100

while a <= 200

if a mod 3 = 0 then print aa = a + 1

wend

end sub

vb輸出100-200之間不能被3整除的數

4樓:匿名使用者

private sub form_click() '單擊窗體時執行下面**

dim i as integer, row as integer '定義i、row為整形變數

cls '清除窗體上原來的文字

print "100-200之間不能被3整除的數有:" '在窗體上大印出引號內的文字

print '空一行

print '空一行

row = 0 '給整形變數row賦值0

for i = 100 to 200 'i的值在100至200範圍內以此變化

if i mod 3 <> 0 then '如果i除以3的餘數不等於0,則執行下面語句

row = row + 1 '變數row的值增加1

print i & " "; '在窗體上列印i的值,後面跟幾個空格,但不換行

end if '

if row mod 12 = 0 then print '如果變數row的值是12的倍數(row除以12的餘數為0),則換行

next i '

end sub

'1.倒數第三行用完if...then後怎麼沒有語句或語句組?也沒有end if?

'then後面的print就是語句。if...then單行時不能加end if。

'2.還是這一行,最後那個print是幹什麼的?為什麼沒了它,系統會提示「next沒有for」?

'print是列印的意思,後面沒有變數或字串就表示什麼也不列印,一般用於換行

'如果沒有它,那麼在then後面沒有語句,就表示這是if...then的多行塊用法,下一行的next i系統認為是在下面塊用法中間

'if 條件語句 then

'結論語句

'else

'結論語句

'endif

'所以,系統會提示「next沒有for」

'3.請為每一句**加上註釋

''4.順便問一下,<>是什麼意思?是不等於嗎?

'<>就是不等於

5樓:匿名使用者

1)if row mod 12 = 0 then print句中print列印空行.

2)<>表示不等於.

摘自msdn

用 if...then 結構有條件地執行一個或多個語句。單行語法和多行塊語法都可以使用:

if condition then statementif condition then

statements

end if

6樓:

1、如果條件語句寫在一行的話,最後可以沒有end if2、沒有了print輸出,上面的if...then...就和 next i連成一句了。

3、這個您應該可以看懂的,不用每句都加註釋吧。

4、確定的告訴您,<>是什麼意思就是不等於

7樓:清山媚水

if ... then ... 叫單行 ifif ... then

...endif

if ... then

...else

...endif

等等 叫 塊if

推薦使用塊if

<> 是 不等於

8樓:聖靈騎士金鋒

1。 用完if...then後怎麼沒有語句或語句組是用於換行,對於end if只是用於豎著寫的,就是你倒數第三句上面那種形式;

2。 用於換行回車;

出現這一句是因為如果if...then是橫著一句寫的形式如果then後面沒有語句啦,要加end if;

3。 private sub form_click()

dim i as integer, row as integer /*定義變數*/

cls /*清屏*/

print "100-200之間不能被3整除的數有:"/*輸出漢字提示*/

print /*回車*/

print

row = 0 /*變數初始*/

for i = 100 to 200

if i mod 3 <> 0 then /*i對3取模看看是否能被三整除*/

row = row + 1

print i & " "; /*輸出數字與空格即用空格將數字隔開*/

end if

if row mod 12 = 0 then print /*沒輸出4個數就換行*/

next i

end sub

4。。是不等於的意思

9樓:

private sub form_click()dim i as integer, row as integercls '清除窗體

print "100-200之間不能被3整除的數有:"

print

print

row = 0

for i = 100 to 200

if i mod 3 <> 0 then 『求餘row = row + 1 』計數

print i & " ";

end if

if row mod 12 = 0 then print 『在窗體上每一行顯示12個不能被3整除的數

next i

end sub

(1)、print就算一個語句,因為語句與if寫在同一行,所以不用end if。

(2)、print是換行,如果去掉,next歸入if語句裡面,next成為語句!所以會提示next沒有for。

(4)、<>是不等於的意思!!

程式設計要求輸出200~400之間不能被五整除,且能被3整除的數。求大神幫忙

10樓:兄弟連教育北京總校

效率最低的basic程式:

dim i as integer

for i=200 to 300

if (i mod 5<>0) and (i mod 3=0) then print i

next

VB程序編寫,VB程式編寫

新增兩個控制元件,一個按鈕,一個label1控制元件陣列,label1 0 label1 1 private sub form load pi 3.14159265358979end sub private sub text1 change label1 0 caption sin text1.te...

用VB編寫程式,用VB編寫一個程式

樓上的,不許要引用吧 option explicit private declare function getdrivetype lib kernel32 alias getdrivetypea byval ndrive as string as long private declare funct...

vb編寫程式計算如下分段函式並輸出結果其中值

dim x as integer inputbox 請輸入值 dim result as integer 你的計算 msgbox result 1 vb6.0編寫程式,計算下列分段函式,要求輸入x的值,輸出y的值。30分,其中介面設計詳細全面2分 1 編 來寫程式,計算下列分段源函式,要求輸入x的值...