Upgrading to .NET, help ?

Netherdrake

Member
Joined
Mar 17, 2010
Messages
7
Programming Experience
Beginner
I have upgraded 16591 lines of code program from VB6 to .NET.
There was a lot of errors and warning that i fixed but i stuck on those.

First one comes here:
VB.NET:
	Function FoundBotName(ByRef thebotname As String) As Object
		Dim check As Short
		'UPGRADE_WARNING: Couldn't resolve default property of object FoundBotName.
		FoundBotName = True
		Do 
			check = check + 1
			If LCase(BotName(check)) = LCase(thebotname) Then Exit Function
		Loop Until check = BotMax
		'UPGRADE_WARNING: Couldn't resolve default property of object FoundBotName.
		FoundBotName = False
	End Function
Couldn't resolve default property of object FoundBotName

Second one:

VB.NET:
    Function BotsInSector(ByRef theSectorNumber As Short, ByRef theZone As Short) As String
        Dim check As Short
        Do
            check = check + 1
            If BotSector(check) = theSectorNumber And theZone = BotZone(check) And BotHull(check) <> 0 Then
                BotsInSector = "," & BotShipClass(check) & BotShipKind(check) & BotName(check) & "," & BotGuild(check) & BotsInSector
            End If
        Loop Until check = BotMax
        Return Nothing
    End Function

Variable BotsInSector is used before it has been assigned a value. A null reference exception could result at runtime.

And the last one:

VB.NET:
	Function HomeEncrypt(ByRef Message As String, ByRef ****youcodetheif As Short) As String
        If Len(Message) = 0 Then Exit Function

Function HomeEncrypt doesn't return a value on all code paths. A null reference exception could occurs at runtime when the result is used.

Thanks in advance.

- Netherdrake
 
Last edited:
I said function return type, not return value. Types are declared with the As clause, for example "As Boolean". See Function Statement (Visual Basic)
This is the most typical signature (snip from that article), I highlighted the part you most likely have not defined:
Function name [ (parameterlist) ] [ As returntype ]
If you don't define a type (this goes for variables and properties also) the default Object type is assumed. I think the "Couldn't resolve default property of object" conversion warning is a catch-all where type is not defined, or where Object type used.
 
Back
Top