如何将图像分配给整数? [英] How to assign an image to an integer?
本文介绍了如何将图像分配给整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于一个类项目,我在VB中制作老虎机。我需要设计它,以便将九个图像中的每一个分配给一个整数,并为每个槽选择1到9之间的随机整数。然后相应的图像将出现在插槽中。我有
用于随机化1到9之间的整数的代码,但是如何将图像分配给整数?
For a class project I'm making a slot machine in VB. I need to design it so that each of nine images is assigned to an integer, and a random integer between 1 and 9 is selected for each slot. The corresponding image will then appear in the slot. I have the code for randomizing an integer between 1 and 9 done, but how would I assign an image to an integer?
推荐答案
Put列表中的图像,然后使用列表索引来引用图像。
Put the images in a list and then use the list index to refer to the images.
Public Class Form3
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim myBmpList As New List(Of Bitmap)
myBmpList.Add(New Bitmap("c:\bitmaps\bg1.png"))
myBmpList.Add(New Bitmap("c:\bitmaps\rusty.jpg"))
Me.BackgroundImage = myBmpList(1)
End Sub
End Class
这篇关于如何将图像分配给整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文