如题所述
第1个回答 推荐于2017-10-24
Try
If PictureBox1.Image.ToString <> "" Then
Label1.Text = "有图像"
End If
Catch ex As Exception
Label1.Text = "无图像"
End Try
VB.Net 用代码为picturebox 打开一张图片:
Dim fn As String = "D:\test.jpg"
'方法1
Me.PictureBox1.ImageLocation = fn
'方法2
Me.PictureBox1.Image = Image.FromFile(fn)
If PictureBox1.Image.ToString <> "" Then
Label1.Text = "有图像"
End If
Catch ex As Exception
Label1.Text = "无图像"
End Try
VB.Net 用代码为picturebox 打开一张图片:
Dim fn As String = "D:\test.jpg"
'方法1
Me.PictureBox1.ImageLocation = fn
'方法2
Me.PictureBox1.Image = Image.FromFile(fn)
第2个回答 2016-04-06
可以使用picturebox1.image.tostring是否为空来判断本回答被提问者采纳