BYTEINSIGHT
GAPVelocity AI Studio helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
This EWI is emitted when a function pointer is used in the original Visual Basic 6 code. In .NET, this is an unmanaged operation and has been replaced by delegates.
Define a delegate for the function and use it instead of using the Long address values.
PublicDeclareFunction SetTimer Lib"user32" _
(ByVal hwnd AsLong, _
ByVal nIDEvent AsLong, _
ByVal uElapse AsLong, _
ByVal lpTimerFunc AsLong) AsLong
PublicFunction UsingAddressOf() AsInteger
Dim TimerId AsLong
TimerId = SetTimer(0, 0, 500, AddressOf TestSub)
UsingAddressOf = TimerId
EndFunction
PublicFunction TestSub(ByVal Message AsString) AsBoolean
If Message <> ""Then
MsgBox(Message)
TestSub = True
Else
TestSub = False
EndIf
EndFunction
PublicDeclareFunction SetTimer Lib"user32" (ByVal hwnd AsInteger, ByVal nIDEvent AsInteger, ByVal uElapse AsInteger, ByVal lpTimerFunc AsInteger) AsInteger
PublicFunction UsingAddressOf() AsInteger
'UPGRADE_WARNING: (1048) Add a delegate for AddressOf TestSub
Dim TimerId AsInteger = SetTimer(0, 0, 500, AddressOf TestSub())
Return TimerId
EndFunction
PublicFunction TestSub(ByRef Message AsString) AsBoolean
If Message <> ""Then
MessageBox.Show(Message, Application.ProductName)
ReturnTrue
Else
ReturnFalse
EndIf
EndFunction
:
PublicDeclareFunction SetTimer Lib"user32" (ByVal hwnd AsInteger, ByVal nIDEvent AsInteger, ByVal uElapse AsInteger, ByVal lpTimerFunc As DelegateOfFunction) AsInteger
PublicDelegateFunction DelegateOfFunction(ByVal Message AsString) AsBoolean
PublicFunction UsingAddressOf() AsInteger
Dim TimerId AsInteger = SetTimer(0, 0, 500, TestSub)
Return TimerId
EndFunction
DllImport("user32.dll")]
externpublicstaticint SetTimer( int hwnd, int nIDEvent, int uElapse, int lpTimerFunc);
staticpublicint UsingAddressOf()
{
//UPGRADE_WARNING: (1048) Add a delegate for AddressOf TestSub
int TimerId = SetTimer(0, 0, 500, TestSub());
return (int) TimerId;
}
staticpublicbool TestSub( string Message)
{
if (Message != "")
{
MessageBox.Show(Message, Application.ProductName);
returntrue;
}
else
{
returnfalse;
}
}
[DllImport("user32.dll")]
externpublicstaticint SetTimer(int hwnd, int nIDEvent, int uElapse, DelegateOfFunction lpTimerFunc);
publicdelegatebool DelegateOfFunction(string message);
staticpublicint UsingAddressOf()
{
int TimerId = SetTimer(0, 0, 500, TestSub);
return (int) TimerId;
}