PictureBox

更改圖片顯示位置

PictureBox1.Location = New Point(100,100)

更改圖片

使用Image屬性

poker.My.Resources.Resources.0  (0.jpg) '專案內的圖片(必須先行匯入)

Dim newImage As Image = Image.FromFile("D:\pic\0.jpg") '外部磁碟機資料夾的圖片

PictureBox1.Image = newImage

使用ImageLocation屬性

指定圖片位置:PictureBox1.ImageLocation = "D:\pic\10.jpg"

使用專案資源

依照參考文獻,先將檔案匯入Resource內。

Dim resourceName As String = poker_index.ToString() '在資源檔裡的檔案編號(索引)

Dim img As Image = CType(My.Resources.ResourceManager.GetObject(resourceName), Image)

PictureBox1.Image = img;

參考文獻

https://slmtsite.blogspot.com/2016/10/c-39-picturebox.html

Poker隨機取得1~52資源索引

Randomize()

Dim poker_index As Integer

poker_index = CInt(Int(52 * Rnd() + 1)) '隨機取 1~52

Dim resourceName As String = poker_index.ToString()

Dim img As Image = CType(My.Resources.ResourceManager.GetObject(resourceName), Image)

PictureBox1.Image = img

Image屬性清空

PictureBox1.Image = Nothing

Resource圖片檔案匯入

PictureBox_Resource_Import.mp4