some notes about vb6 to vb.net conversion based on syntax
Conversion history and architecture will be published later...
fixed sized string with default value
VB6 ;
Dim sTempPath As String
sTempPath = String(255, vbNullChar)
VB.NET ;
Dim sTempPath As String
sTempPath = New String(CChar(vbNullChar), 255)
2-
Current Date
VB6 ;
sLogData = Date & " User : " & PMP_USER_NAME
VB.NET;
sLogData = Date.Today & " User : " & PMP_USER_NAME
3-
Null value
VB6;
sDate = Null
VB.NET;
sDate = Nothing
4- Default Property(Attribute)
VB6;
Tools Menu
Procedure Attribute
Select "Name" for Property
click "Advanced" button
set "Procedure ID" combo box and select "(Default)"
VB.NET;
add "Default" into Property such as :
Default Public ReadOnly Property Item (IndexKey As Object) As clsItem
5- Equivalent of Mouse Pointer
VB6;
Screen.MousePointer = vbHourglas
VB.NET;
add Windows.Form Reference then
Cursor.Current = Cursors.WaitCursor
6- Equivalent of Timer
VB6;
Timer
VB.NET;
DateTime.Now.TimeOfDay.TotalSeconds
7- Week of day
VB6;
VBA.Weekday(dateParam,firstDayOfWeekParam)
VB.NET;
Date.DayOfWeek
8- Get/Set Screen Width/Height
VB6;
Screen.Width
Screen.Height
VB.NET;
Add System.Drawing Assembly as reference then
Screen.PrimaryScreen.WorkingArea.Width
Screen.PrimaryScreen.WorkingArea.Height
9- hInstance and ThreadId
VB6;
App.hInstance
App.ThreadID
VB.NET;
System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))
AppDomain.GetCurrentThreadId
10 - Define how to Importing Windows Libraries (Example; Lib "user32") and usage of AddressOf by an example.I think technical definitions can be found easily but implemantation is not.:)
VB6;
Definition =
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
.....
in Class
.....
m_nTimerHookRetVal = SetTimer(0, 0, 5000, AddressOf _EventCodes)
.....
Public Sub _EventCodes (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
.....
events code
...
End Sub
VB.NET;
Public Delegate Sub Delegate_EventCodes (ByVal hwnd As Integer, ByVal nIDEvent As Integer, _
ByVal uElapse As Integer, ByVal lpTimerFunc As Integer)
Declare Function SetTimer Lib "user32" (ByVal hwnd As Integer, ByVal nIDEvent As Integer, ByVal uElapse As Integer, ByVal lpTimerFunc As Delegate _EventCodes ) As Integer
VB6;
VBA.Weekday(dateParam,firstDayOfWeekParam)
VB.NET;
Date.DayOfWeek
8- Get/Set Screen Width/Height
VB6;
Screen.Width
Screen.Height
VB.NET;
Add System.Drawing Assembly as reference then
Screen.PrimaryScreen.WorkingArea.Width
Screen.PrimaryScreen.WorkingArea.Height
9- hInstance and ThreadId
VB6;
App.hInstance
App.ThreadID
VB.NET;
System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))
AppDomain.GetCurrentThreadId
10 - Define how to Importing Windows Libraries (Example; Lib "user32") and usage of AddressOf by an example.I think technical definitions can be found easily but implemantation is not.:)
VB6;
Definition =
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
.....
in Class
.....
m_nTimerHookRetVal = SetTimer(0, 0, 5000, AddressOf _EventCodes)
.....
Public Sub _EventCodes (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
.....
events code
...
End Sub
VB.NET;
Public Delegate Sub Delegate_EventCodes (ByVal hwnd As Integer, ByVal nIDEvent As Integer, _
ByVal uElapse As Integer, ByVal lpTimerFunc As Integer)
Declare Function SetTimer Lib "user32" (ByVal hwnd As Integer, ByVal nIDEvent As Integer, ByVal uElapse As Integer, ByVal lpTimerFunc As Delegate _EventCodes ) As Integer
.....
'handler in class
Private m_handler_EventCodes As Delegate_EventCodes
.......
.......
'in current place
'add below
m_handler_EventCodes = New Delegate_InternalTimerProc(AddressOf _EventCodes )
m_nTimerHookRetVal = SetTimer(0, 0, 5000, m_handler_EventCodes)
.....
Public Sub _EventCodes (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
.....
events code
...
End Sub
Public Sub _EventCodes (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long)
.....
events code
...
End Sub
Comments
Post a Comment