Hey all I am trying to convert a little bit of VB6 to .NET and I am getting the error of:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string " " to type 'Integer' is not valid.
The following .net code is where its getting stuck at CopyMemory(str_Renamed, ptr, count):
Public Function ptrToStr(ByVal ptr As Integer) As String
Dim count As Integer
Dim str_Renamed As String
count = lstrlen(ptr)
If count Then
str_Renamed = New String(vbNullChar, count)
CopyMemory(str_Renamed, ptr, count)
ptrToStr = str_Renamed
Else
ptrToStr = ""
End If
End Function
The values for those varibles are:
count = 4
ptr = 268978536
str_Renamed = " "
I'm not sure how to go about fixing this error...