1樓:
console.writeline("請輸入一個整數:");
int n;
n=int.parse(console.readline());
if(n%5==0&&n%7==0)
{console.writeline(n+"能夠同時被5和7整除");
console.read();
}elsew
{console.writeline(n+"不能夠同時被5和7整除");
console.read();}
2樓:匿名使用者
在窗體新增一個文字框和一個標籤和一個按鈕
private sub command1_click()if val(text1.text) mod 5 = 0 and val(text1.text) mod 7 = 0 then
label1.caption = text1.text & "能同時被5和7整除"
else
label1.caption = text1.text & "不能同時被5和7整除"
end if
end sub
3樓:匿名使用者
你新建一個窗體,上面text、label、command控制元件各一個
private sub command1_click()
if not isnumeric(text1.text) then exit sub
if val(text1.text) mod 5 = 0 and val(text1.text) mod 7 = 0 then
label1.caption = text1.text & "能同時被5和7 整除"
else
label1.caption = text1.text & "不能同時被5和7 整除"
end if
end sub
4樓:喻元愷
_partial class form1
inherits system.windows.forms.form
'form 重寫 dispose,以清理元件列表。
_protected overrides sub dispose(byval disposing as boolean)
tryif disposing andalso components isnot nothing then
components.dispose()
end if
finally
mybase.dispose(disposing)
end try
end sub
'windows 窗體設計器所必需的
private components as system.componentmodel.icontainer
'注意: 以下過程是 windows 窗體設計器所必需的
'可以使用 windows 窗體設計器修改它。
'不要使用**編輯器修改它。
_private sub initializecomponent()
me.button1 = new system.windows.forms.button
me.textbox1 = new system.windows.forms.textbox
me.label2 = new system.windows.forms.label
me.label1 = new system.windows.forms.label
me.suspendlayout()
''button1
'me.button1.location = new system.drawing.point(26, 82)
me.button1.name = "button1"
me.button1.size = new system.drawing.size(75, 23)
me.button1.tabindex = 0
me.button1.tag = ""
me.button1.text = "開始判讀"
me.button1.usevisualstylebackcolor = true
''textbox1
'me.textbox1.location = new system.drawing.point(115, 28)
me.textbox1.name = "textbox1"
me.textbox1.size = new system.drawing.size(159, 21)
me.textbox1.tabindex = 2
''label2
'me.label2.autosize = true
me.label2.location = new system.drawing.point(129, 87)
me.label2.name = "label2"
me.label2.size = new system.drawing.size(65, 12)
me.label2.tabindex = 3
me.label2.text = "判讀結果:"
''label1
'me.label1.autosize = true
me.label1.location = new system.drawing.point(12, 31)
me.label1.name = "label1"
me.label1.size = new system.drawing.size(89, 12)
me.label1.tabindex = 3
me.label1.text = "請輸入一個數字"
''form1
'me.autoscaledimensions = new system.drawing.sizef(6.0!, 12.0!)
me.autoscalemode = system.windows.forms.autoscalemode.font
me.clientsize = new system.drawing.size(360, 138)
me.controls.add(me.label1)
me.controls.add(me.label2)
me.controls.add(me.textbox1)
me.controls.add(me.button1)
me.formborderstyle = system.windows.forms.formborderstyle.fixedtoolwindow
me.name = "form1"
me.text = "form1"
me.resumelayout(false)
me.performlayout()
end sub
friend withevents button1 as system.windows.forms.button
friend withevents textbox1 as system.windows.forms.textbox
friend withevents label2 as system.windows.forms.label
friend withevents label1 as system.windows.forms.label
end class
public class form1
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.
click
dim i as integer
if me.textbox1.text.trim() <> string.empty then
i = cint(me.textbox1.text.trim())
if i mod 5 = 0 and i mod 7 = 0 then
me.label2.text = "判讀結果:" + i.tostring() + "能夠被 5 和 7 同時整除"
else
me.label2.text = "判讀結果:" + i.tostring() + "不能夠被 5 和 7 同時整除"
end if
end if
end sub
end class
j**a程式設計,鍵盤輸入一個整數,判斷能否被5和6整除,再判斷能否被5或6整除?
vb程式設計題:單擊窗體,在窗體上顯示1~200之間既能被5整除又能被7整除的數的和
5樓:匿名使用者
private sub form_click()dim i as long, a as longa = 0
for i = 1 to 200
if i mod 5 = 0 and i mod 7 = 0 then
print i
a = a + i
end if
next
print "以上是同時被5和7整除的數,和=" & aend sub
6樓:精樸電池
' 單擊窗體函式裡面的**:
dim i as integer ' 從1~200dim count as integer ' 儲存所求的和for i=1 to 200
if (i mod 5 = 0) and (i mod 7 = 0) then
count = count + i
end if
next i
7樓:
for迴圈1到200,執行除5為ture再除7 ,ture就壘加到變數裡。
**就不給了,很簡單。
VB文字框組資料更新,VB文字框如何每輸入一個資料換一行
假設你的控制元件陣列名稱為text1 你可按實際情況改一下 下標要從0開始 從上到下連續的 如果你介面設計時正常操作,就是這個規律 private sub command1 click dim i as long,j as longdim n as long n 7 控制元件陣列中的 textbox...
vb文字框中 怎麼改變字型大小,VB文字框中 怎麼改變字型大小
改變fontsize屬性,如 private sub command1 click text1.fontsize text1.fontsize 2 end sub vb文字框中 怎麼改變字型大小 在vb上面加上combo 和 textbox 文字框 控制元件,並輸入以下 在form load中加入字...
VB6中兩個文字框數字相加,自動顯示在文字框,如何實現,請注意是自動顯示,而不是點選後顯示
未必66兩個文字框數字相加自動顯示在地上門框。如何實現?那你把第三款看著比較就可以寫出來的唄。vb中怎麼將兩個文字框中的數字相加在第三個文字框中顯示 private sub command1 click text3.text val text1.text val text2.text end sub...