VB6向VB.Net2005迁移相关知识
转自(http://blog.csdn.net/babyt/article/details/4610131)
问:
這是VB6.0在Module裡定義的,
Declare Function rf_halt Lib "mwrf32.dll" (ByVal Icdev As Long) As IntegerDeclare Declare Function rf_authentication Lib "mwrf32.dll" (ByVal Icdev As Long, ByVal mode%, ByVal scenr%) As Integer
..........................................
..........................................
..........................................
定義好多類似的,只是參數值不同,是這樣引用的:st=rf_halt(Icdev)),
St = rf_authentication(Icdev, LoadMode, Sector),現在
想改成VB.NET 2005,要怎樣改?急....謝謝....
答:
是要修改如何声明吗?
Declare Function rf_halt Lib "mwrf32.dll" (ByVal Icdev As Long) As Integer
Declare Declare Function rf_authentication Lib "mwrf32.dll" (ByVal Icdev As Long, ByVal mode%, ByVal scenr%) As Integer
改为:
Declare Function rf_halt Lib "mwrf32.dll" (ByVal Icdev As Integer) As Int32
Declare Declare Function rf_authentication Lib "mwrf32.dll" (ByVal Icdev As Integer, ByVal mode As Int16, ByVal scenr As Int16) As Int16
问:
vb6代码:
Private Declare Function SMSDeliver_ReportCallBack Lib "third_gw " (ByVal Deliver_Report As Long) As Long
Private Sub Command2_Click()
SMSDeliver_ReportCallBack AddressOf Deliver2
End Sub
Public Sub Deliver2(ByRef re_type As Long)
......
End Sub
转换为。net后提示要用“委托”,怎么实现?
答:
Private Declare Function SMSDeliver_ReportCallBack Lib "third_gw " ( _
ByVal lpfn As PROC) As Integer
Public Delegate Function PROC(ByRef re_type As Integer) As Integer
Public gobjDelegate As PROC=New PROC(AddressOf Deliver2)
Public Sub Deliver2(ByRef re_type As Integer)
......
End Sub
Private Sub Command2_Click()
SMSDeliver_ReportCallBack(gobjDelegate)
End Sub
问:
我现在有个图表的控件,要转换成.net的,这个图表控件大量用了line方法
看msdn现在应该用drawline方法了,但是两个方法形式相差太多,我想自己写个
line方法,但是Line [ [Step] (x1,y1)]-(x2,y2)[,颜色][,B[F]]的这种
形式怎么变成相近的.net方法阿,像Line [Step] (x1,y1)]-(x2,y2)表示两个点
这算什么语法现象阿,好像vb6写个函数也不能这样嘛
大家给点意见,谢谢
答:
vb6
Picture1.Line (x1,y1)-(x2, y2), &HFFFFFF
.net
Dim PicDC As Graphics
PicDC = picturebox1.CreateGraphics
PicDC.DrawLine(New Pen(Color.Red), x1, y1, x2, y2)
Imports System.Reflection.Assembly
Imports System.Diagnostics.FileVersionInfo
’App.Path
Application.StartupPath
’App.Title
GetExecutingAssembly.GetName.Name
’App.ExeName
GetExecutingAssembly.Location
’App.Major
GetVersionInfo(GetExecutingAssembly.Location).ProductMajorPart
’App.Minor
GetVersionInfo(GetExecutingAssembly.Location).ProductMinorPart
’App.Revision
GetVersionInfo(GetExecutingAssembly.Location).ProductBuildPart
’App.LegalCopyrights
GetVersionInfo(GetExecutingAssembly.Location).LegalCopyright
’App.LegalTrademarks
GetVersionInfo(GetExecutingAssembly.Location).LegalTrademarks
’App.CompanyName
GetVersionInfo(GetExecutingAssembly.Location).CompanyName
相关资源:
http://msdn.microsoft.com/zh-cn/library/ywsayxak(VS.80).aspx
http://www.applevb.com/art/vbnet1.htm
http://www.accessbbs.cn/bbs/blog/?1979/action_spacelist_type_blog.html
本项目使用:
VB需安装sp6/原项目中删除DAO的引用,先全部更改为ADO
几个关键函数的转换
http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=3308070&SiteID=14
http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=3308070&SiteID=14
http://www.softwelt.com/Know/KnowDetail-5167860.html
将VB6中Line的两个端点转换为.Net中的Label的Top(X)/Left(Y)以及长度