用VB求數的最大數,用VB求五個數的最大數

2022-01-03 16:03:26 字數 728 閱讀 3289

1樓:匿名使用者

function maxnum(a, b, c, d, e) as long

dim arr(0 to 5)

dim i as long

arr(1) = a

arr(2) = b

arr(3) = c

arr(4) = d

arr(5) = e

for i = 1 to ubound(arr)if maxnum < arr(i) thenmaxnum = arr(i)

end if

next

end function

在陣列中用迴圈實現,很簡單的,如果maxnum比陣列中的數字小的話,將比他大的數字付給maxnum執行完後,maxnum就是陣列中的最大值、 用迴圈寫演算法比較易讀,精簡,邏輯清晰。如果可以吧五個數字也寫在一個陣列中。

2樓:環業軟體

function func(a, b, c, d, e)dim k as single

k = a

if k < b then k = b

if k < c then k = c

if k < d then k = d

if k < e then k = e

func = k '''*********************************加這句

end function

求vb的求數平方的程式設計,求一個vb的求一個數平方的程式設計

樓主您好!什麼也不用畫,直接複製貼上 簡單就一句 msgbox 這個數的平方為 val inputbox 請輸入要求平方的數 提示視窗 2 64 vbokcancel vbdefaultbutton1,提示視窗 多寫點就這樣 dim number1 as double dim number2 as ...

用VB做了類似記事本的程式,用VB做了一個類似記事本的程式

二句先後問題 commondialog1.showopencommondialog1.filter 文字檔案 txt 應該commondialog1.filter 文字檔案 txt commondialog1.showopen 我用vb編了一個記事本程式,可就是不能像windows的記事本一樣用tx...

求大神幫忙,用VB設計程式,有兩個題目

dim a as integer,b as integer,t as integer,s as integer private sub command1 click if option1.value true then msgbox a b str a b else if option2.value...