三国大时代4神兽在哪:vb 程序设计

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 00:06:41
1、用do until ...loop语句求两个数的最大公约数.
2、用双重循环编程输出如下图形

***
*****
*******
*********
*******
*****
***

1.弄2个文本框,一个按钮。本框输数字,按钮计算结果,代码如下:
Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
Do Until b = 0
c = b
b = a Mod b
a = c
Loop
MsgBox c
End Sub
2.弄一个按钮,代码如下:
Private Sub Command1_Click()
Const s$ = "*"
Dim i As Integer, j As Integer
Cls
Me.AutoRedraw = True
For i = 1 To 9
For j = 1 To 9 - Abs(5 - i) * 2
Print s$;
Next j
Print
Next
End Sub

1、
founction gcd(x as integer,y as integer)as integer
do while y=0
r=x mod y
x=y
y=r
loop
gcd=x
end founction
2、
sub printstar()
dim i as long,j as long
for i=1 to 5
for j=1 to 2*i-1
print "*"
next j
print
next i
for i=4 to 1 step -1
for j=1 to 2*i-1
print "*"
next j
print
next i
end sub