您的位置:程序门 -> .net技术 -> vb.net



菜鸟第一次提问,各位大人多帮忙啊


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


菜鸟第一次提问,各位大人多帮忙啊[已结贴,结贴人:smszw3370]
发表于:2007-11-14 10:13:14 楼主
我用vb6写过些程序,现在在学vb.net。
先下了个例子,是关于图像的,叫potovison
我用的是vs2005,打开这个项目后自动转换,然后发现提示有81个警告,举几个例子:
第一个:
protected   overrides   sub   onclosing(byval   e   as   system.componentmodel.canceleventargs)
if   dialogresult   =   dialogresult.ok   then
[global].settings.setvalue(settingkey.servicepassword,   _
dataprotection.encrypt(textpassword.text,   dataprotection.store.user))
end   if

mybase.onclosing(e)
end   sub

其中dialogresult.ok建议要用windows.forms.dialogresult.ok,信息是“通过实例访问共享成员、常量成员、枚举成员或嵌套类型,将不计算限量表达式。”

第二个:
private   sub   getinfo()
dim   image   as   bitmap
try
image   =   new   bitmap(_pathcur)
textcurrent.text   =   getphotoinfo(_pathcur,   image)
pictcurrent.image   =   photohelper.getthumbnail(image,   pictcurrent.width)
image.dispose()
image   =   new   bitmap(_pathnew)
textnew.text   =   getphotoinfo(_pathnew,   image)
pictnew.image   =   photohelper.getthumbnail(image,   pictnew.width)
catch   ex   as   exception
finally
if   not   (image   is   nothing)   then   image.dispose()
end   try
end   sub
最后一行的image说是“变量在赋值前被使用,可能会在运行时导致空引用异常。”

第三个:
public   shared   function   isvalidalbumname(byval   name   as   string)   as   boolean
dim   reg   as   regex
if   reg.ismatch(name,   consts.invalidalbumpattern)   then   return   false
if   name.length   =   0   orelse   name.length   >   consts.maxalbumlength   then   return   false
if   name.startswith(".")   orelse   name.endswith(".")   then   return   false
return   true
end   function

提示“未使用局部变量reg”

第四个:
public   function   display(byval   parent   as   control)   as   dragdropeffects
contextmenu.show(parent,   parent.pointtoclient(parent.mouseposition))
application.doevents()

return   _effect
end   function

这个是我最不理解的,它提示将parent.mouseposition换成control.mouseposition,警告内容同第一个例子。
发表于:2007-11-14 10:21:011楼 得分:20
quick   details
file   name: fotovision.exe
version: 1.1
date   published: 6/23/2004

注意版本...显然是vs2003项目...
发表于:2007-11-14 10:24:552楼 得分:0
怎么贴出来后代码的缩进格式都没有了?
请各位帮我解释一下,谢了!
发表于:2007-11-14 10:32:433楼 得分:0
to   vrhero:
谢谢这么快回复。能否说详细些?如果是版本问题,是否该按提示的修改,尤其是第四种情况?
发表于:2007-11-14 10:36:194楼 得分:0
警告可以忽略但不能保证运行时没有异常...你可以按提示的修改...

这种警告是因为新的特性取代了即将被淘汰的特性...但在一定程度上仍然兼容...
发表于:2007-11-14 10:38:205楼 得分:0
可以忽略很多警告的
发表于:2007-11-14 11:02:216楼 得分:0
那第四种情况也可以按提示改吗?parent变量是传入的啊,改成control合适吗?

还有,在这个论坛里如何给别人分呢?
发表于:2007-11-15 09:36:307楼 得分:30
第二个:
dim   image   as   bitmap   =   nothing
第三个:
删除   dim       reg       as       regex
直接用   regex.ismatch


快速检索

最新资讯
热门点击