VB用print窗體顯示楊輝三角

時間 2021-08-11 17:10:49

1樓:匿名使用者

private sub form_click()dim a() as long, n as long, i as long, j as long, x as long

n = val(inputbox("請輸入列印行數<=16", "輸入正整數", 16))

if n > 16 or n <= 0 thenmsgbox "數值錯誤,重新輸入行數"

n = 0

end if

redim a(n, n)

me.cls

for i = 1 to n

for j = 1 to i

if j = 1 or i = j thena(i, j) = 1

else

a(i, j) = a(i - 1, j - 1) + a(i - 1, j)

end if

next j

next i

for i = 1 to n

print spc(75 - 3 * i);

for j = 1 to i

print a(i, j);

x = len(cstr(a(i, j)))if x = 1 then print spc(3);

if x = 2 then print spc(2);

if x = 3 then print spc(1);

next j

print

print

next i

end sub

2樓:匿名使用者

private sub form_click()dim i as integer, j as integer, m as integer

m = inputbox("請輸入陣列的行、列數")redim a(m, m) as integercall p(a, m)

for i = 1 to m

for j = 1 to i

print tab(j * 3); a(i, j);

next j

print

next i

end sub

private sub p(b() as integer, n as integer)

dim i as integer, j as integerfor i = 1 to n

b(i, 1) = 1: b(i, i) = 1next i

for i = 3 to n

for j = 2 to i - 1

b(i, j) = b(i - 1, j - 1) + b(i - 1, j)

next j, i

end sub

vb中print語句怎麼用,VB中Print語句怎麼用?

樓主如果還是做不出來的話,可以把郵箱留下,我把我用vb6.0做的乙個例子給你發過去,解壓之後就能執行了,你可以參考下。好像你的郵箱是qinyehong 126.com是吧?我已經發過去了。 豆漠義友珊 print a 是輸出字串a 就是直接輸出引號內的。print a是輸出程式內 a的當前值 pri...

vb更改窗體名稱

vb執行時無法更改窗體的name屬性,只能在設計時更改。窗體的caption 屬性是可以在執行時更改的。caption 屬性 窗體 確定顯示在 form 或 mdiform 物件的標題欄中的文字。當窗體為最小化時,該文字被顯示在窗體圖示的下面。控制項 確定顯示在控制項中還是附在控制項之後的文字。me...

vb中怎樣讓窗體不能夠拉伸,vb 窗體大小不得改變

艹,不懂就別回答,浪費表情,把mdichild false,就可以了,不最大化是maxbutton設為false,不最小化minbutton設為false,如果是正解,頂一下哦 窗體不能改變大小 borderstyle設為1 minbutton設為true。方法一 設定窗體的borderstyle ...