1樓:匿名使用者
private sub ***mand1_click()dim i as integer, j as integer, k as integer
dim a(1 to 10) as integerdim max as integer, min as integer, pj as single
dim sumnum as integer, s as string'初始化
i = 10: j = 99 '定義兩位整數區間sumnum = 0
'產生一個在[10,99]之間的兩位整數
for k = 1 to 10
a(k) = int(i + rnd * (j - i + 1))next k
max = a(1): min = a(1)'找出最大值,最小值,平均值
for k = 1 to 10
sumnum = sumnum + a(k) '計算十個數的和'找出最大值
if a(k) > max then
max = a(k)
end if
'找出最小值
if a(k) < min then
min = a(k)
end if
next k
pj = sumnum / 10
for k = 1 to 10
s = s & a(k) & " "
next k
form1.cls
print "10個隨機值是:" & s
print "最大值為:" & max
print "最小值為:" & min
print "平均值為:" & pj
end sub
vb程式設計題目
2樓:鄭桂蘭韶巳
窗體上新增2個文字框和1個按鈕,文字框用來顯示2個同學名字private
sub***mand1_click()
'交換名字
dims
asstrings=
text1.text
text1.text
=text2.text
text2.text=s
endsub
vb程式設計題目
3樓:匿名使用者
private sub ***mand1_click()if len(text1) >= 2 thentext1 = left(text1, 2)end if
end sub
private sub ***mand2_click()text1 = ""
end sub
private sub form_load()label1.caption = "新字串"
***mand1.caption = "左邊2個字元"
***mand2.caption = "清空"
text1 = ""
'這裡不知道 三號是多大時,可以手動設定文字框字型大小為三號,然後顯示下字型大小,就知道三號字型等於15.75
print text1.fontsize
text1.fontsize = 15.75text1.forecolor = vbredtext1 = "abcdef"
end sub
4樓:竹貞韻祁許
點選窗體顯示前100項
private
function
sl(i%)
ifi=1
then
sl=0
elseif
i=2then
sl=1
elseif
i=3then
sl=1
else
sl=sl(i-3)+2*sl(i-2)+sl(i-1)endfunction
private
subform1_click()
fori=1
to100
sl(i)
next
iend
sub如果要某個值,應該會的吧
5樓:臧嬋娟揚代
(2)新增***mand1
dima(1
to100)
aslong
dimptr
asinteger
private
sub***mand1_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
6樓:賀淑珍光女
private
sub***mand1_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
sub***mand2_click()
dimss=
inputbox("請輸入一個正整數")
ifstrreverse(s)=s
then
msgboxs&
"是迴文數"
else
msgboxs&
"不是迴文數"
endif
endsub
private
sub***mand3_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 7樓:光秀珍易茶 第一題同意樓上的意見,不過請把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 測試通過 8樓:戴元武甕平 因為固定長度字串、陣列是不允許作為物件模組的public成員的 所以是a哦 1和3是錯的。。。。。 9樓:孔棟濮陽思源 dima aslong,bas long,cas longa= 1b=1 print a;b; dimi asinteger fori=3 to20c= a+bprintc;a =bb= **ext 求vb程式設計題目 10樓:匿名使用者 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 otherequipment = otherequipment + check1(i).caption + vbcrlf end if next i text2.text = text2.text + ***bo1. text + vbcrlf + operatingsystem + vbcrlf + text1.text + vbcrlf + otherequipment end sub private sub form_load() ***bo1.additem "聯想" ***bo1.additem "方正" ***bo1.additem "ibm" ***bo1.additem "***paq" ***bo1.additem "相容 機"end sub private sub option1_click(index as integer) operatingsystem = option1(index).caption end sub vb程式設計題目 11樓:匿名使用者 private function 費用() as singleselect case 上網hour '小時數可以是integer or long '這個時間是在計數器裡累積出來的一個月內的小時數case is <10 費用=30 case is >=10 or is<50費用=30+3*(上網hour-10) case is >=50 費用=30+3*(49-10) +2.5*(上網hour -49)end select if 費用》150 then 費用=150end function vb程式設計小題目 12樓:匿名使用者 五角硬幣: 264個/公斤 = 3.787879克/個 一元硬幣: 165個/公斤 = 6.060606克/個 private sub ***mand1_click() dim i as integer, j as integer, w as single for i = 0 to 528 '五角硬幣數量,兩公斤最多528個硬幣 for j = 0 to 330 '一元硬幣數量,兩公斤最多330個硬幣 w = i * 3.787879 + j * 6.060606 '總重量 if int(w) = 2000 and i + j = 462 then print "一元的硬幣有:" & j & "個" print "五角的硬幣有:" & i & "個" end if next next end sub 最終結果: 一元的硬幣有:110個 五角的硬幣有:352個 13樓:匿名使用者 private sub ***mand1_click()for i = 0 to 462 for j = 0 to 462 if 2 * i / 132 + y / 165 = 2 thenif i + j = 462 then msgbox "五角" & i & " 1元" & jend if end if next j next i end sub a 1在這段 裡面應該是代表了查詢到的匹配字串的位置text3.selstart a 1就是在text3中選中該匹配的字串的起始位置text3.sellength len text2.text 設定text3中選中字串的長度text3.seltext text2.text 就是把text2.text... private sub mand1 click if val text1.text 7 or val text1.text 1 then msgbox 有效數字輸入範圍1 7 exit sub end if text2.text choose val text1.text 一 二 三 四 五 六 日... public function itotal byval n as integer as double dim i as integer,n as integerdim itol as double,inum as double,ix as integer inum 0.3 for i 1 to n...VB程式設計題目講解,vb程式設計題目
vb程式設計題求大神解答,VB程式設計軟體題目,求大神解答謝謝
VB程式設計裡的題目,求詳細程式設計。謝謝了