原程序是这样:
Imports System.Data.SqlClient
Imports System.data
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Security.Cryptography
Imports System.ioPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim temp As Bitmap
temp.FromFile("C:\Inetpub\wwwroot\test\1.bmp")
label1.text=temp.width
end sub
运行后提示:未将对象引用设置到对象的实例有人说需要先判断是否为空值,我改过后运行是没问题了,但点击按钮后label.text显示的还是空
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim temp As Bitmap
if not temp is nothing then
temp.FromFile("C:\Inetpub\wwwroot\test\1.bmp")
label1.text=temp.width
end if
end sub
大家再看看,还可能是哪的问题
Imports System.Data.SqlClient
Imports System.data
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Security.Cryptography
Imports System.ioPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim temp As Bitmap
temp.FromFile("C:\Inetpub\wwwroot\test\1.bmp")
label1.text=temp.width
end sub
运行后提示:未将对象引用设置到对象的实例有人说需要先判断是否为空值,我改过后运行是没问题了,但点击按钮后label.text显示的还是空
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim temp As Bitmap
if not temp is nothing then
temp.FromFile("C:\Inetpub\wwwroot\test\1.bmp")
label1.text=temp.width
end if
end sub
大家再看看,还可能是哪的问题
if not temp is nothing then
label1.text=temp.width
end if
temp.fromfile("c:\inetput\wwwroot\test\1.bmp")
if not temp is nothing then
label1.text=temp.width
else
label1.text="No Picture"
end if
你看看显示的是不是“No Picture”?我估计是,要不然你以前的代码至少也得给你出个0