Private Sub Command1_Click()
Dim n As Long
n = Val(InputBox("输入", "请输入您个年龄", 12))
If n < 18 Then
Print n; "少年"
ElseIf n >= 18 And n < 45 Then
Print n; "青年"
ElseIf n >= 45 And n <= 59 Then
Print n; "中年"
ElseIf n > 59 Then
Print n; "老年"
Else
Print n; "输入年龄错误"
End If
End Sub
Private Sub Command2_Click()
Dim n As Long
n = Val(InputBox("输入", "请输入您个年龄", 12))
Select Case n
Case Is < 18
Print n; "少年"
Case Is > 59
Print n; "老年"
Case Is >= 18
Select Case n
Case Is < 45
Print n; "青年"
Case Else
Print n; "中年"
End Select
Case Else
Print n; "输入年龄错误"
End Select
End Sub
Private Sub Form_Load()
MeCaption = "年龄段划分"
Command1Caption = "使用if"
Command2Caption = "使用select"
End Sub
Private Function yh(n As Integer)
Dim a() As Integer
ReDim a(1 To n, 1 To n)
For i = 1 To n
a(i, 1) = 1
a(i, i) = 1
Next i
For i = 3 To n
For j = 2 To i - 1
a(i, j) = a(i - 1, j) + a(i - 1, j - 1)
Next j
Next i
For i = 1 To n
For j = 1 To i
Print Tab(20 - 2 i + 4 j); a(i, j);
Next j
Next i
End Function
Private Sub Form_Load()
Dim n As Integer
MeShow
n = InputBox("输入行数:")
yh n
End Sub
一:
private sub form_click()
for i=1 to 4
print tab(8-i);string(i,str(i))
next i
二:
1@:
static sum as integer
sum=0
for i=1 to 100
sum=sum+i
i=i(-1)
next i
print "sum=" & str(sum)
2@:
dim x%
x=1
for i=1 to 10
x=xi
next i
print x
3@:
function sum(byval n as integer) as double
static sum as integer
sum=0
for i=1 to n
sum=sum+1
next i
end function
private sub command1_click()
static xs as double
xs=0
for i=1 to 100
xs=xs+sum(i)
next i
print xs
end sub
三:
1:
如下()
2:
option base 1
private sub command1_click()
dim a(20)%
for i=1 to 20
a(i)=rnd100
print a(i)
next i
dim max%
max=a(1)
for i=2 to 20
if a(i)>max then max=a(i)
next i
print str(max)
end sub
四:
private sub comand1_click()
static sum%
sum=0
for i=1000 to 2000
if i mod 400=0 or (i mod 4=0 and i mod 100<>0) then
list1additem str(i)
sum=sum+i
end if
next i
text1=sum
2:
和上题基本上差不多,自己写吧。
以上就是关于vb程序设计测试题全部的内容,包括:vb程序设计测试题、急!2道大学VB程序设计题,希望高手帮忙!(截止至今晚7点)、几道VB程序设计题,帮帮忙!!急要!!多谢等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)