原程序是这样:
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
大家再看看,还可能是哪的问题

解决方案 »

  1.   

    temp.FromFile("C:\Inetpub\wwwroot\test\1.bmp")
       if not temp is nothing then
           label1.text=temp.width
       end if
      

  2.   

    楼上的方法还是不行,label.text照样显示是空
      

  3.   

    当然不一定行,你得保证你那里有那个文件,并且当前登陆的Windows ID有读取它的权限。这样就绝对不会空了
    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
      

  4.   

    是显示“No Picture”,不过那个文件肯定是存在的,当前登陆的也是系统管理员帐号,我现在觉得可能是temp根本没有创建成功,但就是不知道该如何修改。