1樓:
dim a(1 to 80) as integer
dim js() as integer
dim os() as integer
private sub command1_click()
dim i, j, k
randomize
j = 0
text1.text = ""
for i = 1 to 80
a(i) = int(rnd * 90) + 10
text1.text = text1.text & a(i) & " "
if i mod 10 = 0 then text1.text = text1.text & vbcrlf
if a(i) mod 2 = 1 then
redim preserve js(j)
js(j) = a(i)
j = j + 1
else
redim preserve os(k)
os(k) = a(i)
k = k + 1
end if
next
end sub
private function prime(byval n as long) as boolean '返回值=true是素數,false不是素數
dim k as long
if n < 2 then
prime = false
else
prime = true
for k = 2 to n - 1
if (n mod k) = 0 then prime = false: exit for
next k
end if
end function
private sub command2_click()
dim i, j
for i = 0 to ubound(js)
for j = 0 to i
if js(i) < js(j) then t = js(i): js(i) = js(j): js(j) = t
next
next
text2.text = ""
for i = 0 to ubound(js)
text2.text = text2.text & js(i) & " "
if (i + 1) mod 5 = 0 then text2.text = text2.text & vbcrlf
next
end sub
private sub command3_click()
dim i, j as integer
for i = 0 to ubound(os)
for j = 0 to i
if os(i) > os(j) then t = os(i): os(i) = os(j): os(j) = t
next
next
text3.text = ""
for i = 0 to ubound(os)
text3.text = text3.text & os(i) & " "
if (i + 1) mod 5 = 0 then text3.text = text3.text & vbcrlf
next
end sub
private sub command4_click()
dim i, j, sum as integer
text4.text = ""
j = 0
for i = 0 to ubound(js)
if prime(js(i)) then
text4.text = text4.text & js(i) & " "
j = j + 1
sum = sum + js(i)
if j mod 5 = 0 then text4.text = text4.text & vbcrlf
end if
next
text5.text = j
text6.text = sum
end sub
private sub command5_click()
unload me
end sub
vb程式設計題目
2樓:匿名使用者
private sub command1_click()if len(text1) >= 2 thentext1 = left(text1, 2)end if
end sub
private sub command2_click()text1 = ""
end sub
private sub form_load()label1.caption = "新字串"
command1.caption = "左邊2個字元"
command2.caption = "清空"
text1 = ""
'這裡不知道 三號是多大時,可以手動設定文字框字型大小為三號,然後顯示下字型大小,就知道三號字型等於15.75
print text1.fontsize
text1.fontsize = 15.75text1.forecolor = vbredtext1 = "abcdef"
end sub
3樓:臧嬋娟揚代
(2)新增command1
dima(1
to100)
aslong
dimptr
asinteger
private
subcommand1_click()
a(1)=1
a(2)=1
a(3)=2
forptr=4
to23
a(ptr)=a(ptr-3)+2*a(ptr-2)+a(ptr-1)
next
a(23)
endsub
可以改變迴圈的量求不同的值
(1)dim
result
assouble
result=0.5*sin(47*3.14/180)*13*17面積公式0.5×sinα×ab
4樓:賀淑珍光女
private
subcommand1_click()
dimk%,
sum%
sum=0k
=val(trim(inputbox("請輸入正整數k的值")))fori=1
tolen(str(k))
sum=
sum+
val(mid(str(k),
i,1))
next
imsgbox
sumend
subprivate
subcommand2_click()
dimss=
inputbox("請輸入乙個正整數")
ifstrreverse(s)=s
then
msgboxs&
"是回文數"
else
msgboxs&
"不是回文數"
endif
endsub
private
subcommand3_click()
dimmax%,
a(1to
10)as
integer
randomize
max=
0fori=
1to10a(i)
=int(10
+rnd
*90)
ifmax
anda(i) mod3=0 then max= a(i) nextiif max> 0then msgbox maxelse msgbox "無要找的數" endif endsub 5樓:光秀珍易茶 第一題同意樓上的意見,不過請把file1的pattern進行修改第二題的**如下 dims asstring private subdir1_change() file1.path =dir1.path endsub private subdrive1_change() dir1.path =drive1.drive endsub private subfile1_click()s= dir1.path open sfor input as#1 dimst dountil eof(1) line input #1,st text2.text =text2.text&st loop close #1end subprivate subfile1_dblclick() shell "notepad.exe"& s,vbnormalfocus endsub private subform_load() file1.pattern ="*.txt" endsub 測試通過 6樓:戴元武甕平 因為固定長度字串、陣列是不允許作為物件模組的public成員的 所以是a哦 1和3是錯的。。。。。 7樓:孔棟濮陽思源 dima aslong,bas long,cas longa= 1b=1 print a;b; dimi asinteger fori=3 to20c= a+bprintc;a =bb= cnext vb程式設計題, 8樓:聽不清啊 private sub command1_click()dim a(5, 7) for i = 1 to 5 for j = 1 to 6 a(i, j) = int(rnd * 9) + 1a(i, 7) = a(i, 7) + a(i, j)print a(i, j); next j print next i print: print for i = 1 to 5 for j = 1 to 6 a(i, 7) = a(i, 7) + a(i, j)print a(i, j); next j print a(i, 7) next i end sub 9樓:樓磬將流婉 以下兩種方法,都沒有定義使用任何額外變數 方法一:該方法單擊按鈕只能交換一次** private subcmd1_click() pic2.paintpicture pic1.picture,0,0 pic1.paintpicture pic2.picture,0,0 endsub 方法專二:該方法可以不屬停的單擊按鈕並交換**,但是用了窗體作為中間交換媒介 private subcmd1_click() me.picture =pic1.picture pic1.picture =pic2.picture pic2.picture =me.picture me.picture =nothing endsub 10樓:無秉朋佳 這個應該不是很難才對啊 在月份單選按鈕單擊事件中編寫: option1.caption="opnonth" text1.text=longdate 這樣應該可以 給郵箱,發工程,以免自己除錯不出來 private sub command1 click timer1.enabled true end sub private sub command2 click timer1.enabled false timer2.enabled true label1.ca... dim operatingsystem as string,otherequipment as string private sub mand1 click text2.text otherequipment for i 0 to 2 if check1 i value 1 then othereq... private sub mand1 click dim i as integer for i 11 to 999 if i strreverse i and i 2 strreverse i 2 and i 3 strreverse i 3 then print i,i 2,i 3end if ne...VB程式設計題目,vb程式設計題目
求vb程式設計題目,VB程式設計題目
一道VB程式設計題目,求大佬解答,一道vb程式設計題目求大佬解答!!!