1樓:匿名使用者
private sub command1_click()randomize
dim arr(9) as integerfor i = 0 to 9
arr(i) = int(rnd * 100) + 1print arr(i);
next i
print "最小值";funcmin(arr)end sub
public function funcmin(arr() as integer) as integer
imin = lbound(arr)
for i = imin + 1 to ubound(arr)if arr(imin)>arr(i) then imin = inext i
funcmin = arr(imin)
end function
2樓:
我給你貼一份.net版本的程式,語言:vb.net,這是一個控制檯程式,是我使用記事本編寫的一段**,使用vbc.exe編譯器編譯成功,請看如下程式:
'------匯入名稱空間------
imports system
imports microsoft.visualbasic
module test
sub main()
dim lint_param(9) as integer '定義一個陣列,下標從0開始
'迴圈產生10個隨機整數,並列印在螢幕中
for lint_index as short=0 to 9
randomize()
lint_param(lint_index)=int(rnd()*100+1)
console.writeline("item:",lint_index+1,lint_param(lint_index))
next
console.writeline("最小值:",funcmin(lint_param))
console.readline()
end sub
'求陣列最小值
private function funcmin(byval pobj_array() as integer) as integer
dim lint_minvalue as integer
if pobj_array.length<=0 then
funcmin=0
return -1
else
lint_minvalue=pobj_array(0)
end if
for each lint_item as integer in pobj_array
if lint_item
lint_minvalue=lint_item
end if
next
return lint_minvalue
end function
end module
3樓:墨漬
private function funcmin()for i = 1 to 10
if a(i) < b then
b = a(i)
end if
next
print "最小數是:"&b
end function
用vb編寫程式,計算
option explicitdim k,t as singleprivate sub mand1 click for k 2 to 300 step 2t t 1 k next label1.caption t end sub for i 2 to 300 step 2 sum 1 i sum n...
幫忙用vb編寫一段語句
a的值是怎麼樣的?是像你寫的 8點30分 還是時間格式?private sub command1 click dim a as date dim h as long,m as longdim isworktime as longa now h hour a m minute a if h 8 and...
資料庫怎麼編寫儲存過程,用SQL怎樣編寫一個儲存過程?
sql server的語法 create procedure proc name para1 int assql statement mysql的語法 create procedure proc name para1 int sql statement 上面的para1是引數,如果不需要可以省略括號...