| 发表于: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,警告内容同第一个例子。 |
|
|
|
|