VB编写程序:设计一个程序,当单击窗体时,在窗体上显示任意一幅图片。
3个回答
展开全部
Dim num, sum, it(1), n, t, h
Private Sub Form_Click()
File1.Refresh
sum = 0
List1.Clear
For i = 0 To File1.ListCount - 1
t = Split(File1.List(i), ".")(UBound(Split(File1.List(i), ".")))
If LCase(t) = LCase("jpg") Or LCase(t) = LCase("bmp") Or LCase(t) = LCase("gif") Then List1.AddItem File1.List(i): sum = sum + 1
Next
h = Rnds(sum)
Print h
Image1.Picture = LoadPicture(List1.List(h))
End Sub
Private Sub Form_Load()
File1.Visible = 0
List1.Visible = 0
num = -1
End Sub
Function Rnds(ByVal Value)
re:
DoEvents
Randomize
n = Fix(Rnd * Value)
If num = 1 Then num = -1
num = num + 1
it(num) = n
If it(0) = it(1) Then GoTo re
Rnds = n
End Function
'添加image1、file1、list1控件各一个
Private Sub Form_Click()
File1.Refresh
sum = 0
List1.Clear
For i = 0 To File1.ListCount - 1
t = Split(File1.List(i), ".")(UBound(Split(File1.List(i), ".")))
If LCase(t) = LCase("jpg") Or LCase(t) = LCase("bmp") Or LCase(t) = LCase("gif") Then List1.AddItem File1.List(i): sum = sum + 1
Next
h = Rnds(sum)
Print h
Image1.Picture = LoadPicture(List1.List(h))
End Sub
Private Sub Form_Load()
File1.Visible = 0
List1.Visible = 0
num = -1
End Sub
Function Rnds(ByVal Value)
re:
DoEvents
Randomize
n = Fix(Rnd * Value)
If num = 1 Then num = -1
num = num + 1
it(num) = n
If it(0) = it(1) Then GoTo re
Rnds = n
End Function
'添加image1、file1、list1控件各一个
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
.com
压缩包中有4个目录
1中是 前两个syA_1,syA_3
2中是 后面接着的三个syA_1,syA_2,syA_3
三角形 就是判断三角形的
随机数 就是生成随机数并判断的。
请给分,谢谢!!
压缩包中有4个目录
1中是 前两个syA_1,syA_3
2中是 后面接着的三个syA_1,syA_2,syA_3
三角形 就是判断三角形的
随机数 就是生成随机数并判断的。
请给分,谢谢!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询