又一道二級VB題

時間 2022-12-10 00:45:05

1樓:匿名使用者

dim x as integer, y as integer

private sub form_click()

dim a as integer, b as integer

a = 5: b = 3 'a=5 b=3

call sub1(a, b) 呼叫sub1

print a, b 這一行(第三行)不知道怎麼得出的。

print x, y 第四行是18 -10

end sub

private sub sub1(byval m as integer, n as integer)

dim y as integer

x = m + n: y = m - n 'x=m+n=a+b=5+3=8 y=m-n=a-b=5-3=2

m = fun1(x, y) m=18

n = fun1(y, x) n=8

end sub

private function fun1(a as integer, b as integer) as integer '第一次呼叫。

x = a + b: y = a - b 'x=a+b=x+y=8+2=10 y=a-b=x-y=10-2=8

print x, y 第一行是:10 8

fun1 = x + y '返回18(x+y=10+8=18)

end function

private function fun1(a as integer, b as integer) as integer '第二次呼叫,分開來了。

x = a + b: y = a - b 'x=a+b=y+x=8+10=18 y=a-b=y=x=8-18= -10 a=8 b=18

print x, y 第二行是:18 -10

fun1 = x + y '返回8(x+y=18+ -10=8)

end function

2樓:網友

這題主要考的是變數的傳遞,byval是按值傳遞(不會帶會返回值),byref是按位址傳遞(會帶會返回值),預設為byref.

答案:第二行是12 -10

二級c語言的一道題

答案是d。首先,你要知道a 和 a 即兩個加號寫在前面和後面的不同。寫在後面 先運算,再加1 寫在前面 先加1,再運算。所以上面的情況是 第一次進while 發現a 2,b加1後為1,因為while語句裡什麼也不做,所以進入下一次迴圈 第二次進while 發現a 1,b加1後為2,同理,進入下乙個迴...

求助一道VB題

private sub form load dim i as long dim x as long dim sum1 dim sum2 dim sum3 for i 1 to 30 x 100000 sum1 sum1 x next debug.print 窮人給富商的錢為 sum1sum2 0.0...

VB的一道試題,求一道VB題的答案啊。

1.在名稱為form1的窗體上畫乙個名稱為p1的 框,並放入乙個 到 框中。2.通過 vb主選單 工程 部件 控制項 裡 新增 microsoft common dialog control 然後 畫乙個通用對話方塊控制項,更改控制項名稱為 cd1 cd1 控制項 右鍵選單 屬性 標題填 開啟檔案檔...