Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > vb6 to 2008 upgrade getting error "property access must assign to the property"
 

vb6 to 2008 upgrade getting error "property access must assign to the property"

In my vb6 code I have a function that looks like:

public function getword as iword 'iword is a class module with 4 elements
.
.
getword
.
.
end function

When it gets converted to 2008 the "getword" is changed to "getword.text()", and I get the error in the subject.

Ihave beenmaking changes to the vb6 project until I get a pretty clean conversion. I have been able to reduce the number of conversion errors down to 2. I am not very familiar with the code I have to convert. What is the "getword" by itself doing? I have not seen that in vb6, so I am not sure what I should convert it to. It seems to be a rather odd piece of code. I tried changing it to "getword = nothing", but then the program no longer works.

What can I change it to so the conversion goes ok, or what can I change the converted getword.text() to to get rid of the error and have it behave the same as in vb6?
sjunsk  Sunday, November 29, 2009 7:19 AM

Hi sjunsk,

Welcometo MSDN forums!


Error Message "Property access must assign to the property or use its value"
->Cause: You have tried to access a property without assigning to it or using its value.
http://msdn.microsoft.com/en-us/library/ww1128ey.aspx

Calling the getword function will return an object of theiword calss.
Then thiscodegetword.text() means reading the text property value.
Please double check and ensure these:
1. Theiword calss has a Public property named text.
2. The returned iword object from the getword function has been initializedand assigned value to the text property.


Best regards,

Martin Xie

MSDN Subscriber Support in Forum

If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Martin Xie - MSFT  Monday, November 30, 2009 12:24 PM
Hi Martin, thanks for helping with this.

The issue is not with calling the getword function, that works fine, but inside of the getword function itself.

1. The iword class does not have a text property, I am not sure why the upgrade wizard decided to put one in. The getword.text() is in the upgraded code, not the original vb6 code. I am guessing since there was no property reference in the vb6 code, the upgrade wizard made a "default" choice of "text" for the property.

2. The snip of code above for the getword function actually has "getword" on a line all by itself. I have pasted the entire routine below. I do not understand what the "getword" on the line by itself does in vb6. Does it set the function return to nothing? I do not think so because I tried replacing the getword with getword = nothing, but then the program stopped working. I need to know the .net semantic equivalent of putting the function name by itself on a line in a function.

Public Function GetWord(Optional ByVal strWord As String) As iWord

Dim objChar As IChar

Dim objLastChar As IChar

Dim lngPtr As Long

Dim strChar As String * 1

Dim sdDirection As SearchDirection

Dim objFinalWord As iWord

Static sobjWord As iWord

If Len(strWord) Then

sobjWord = New iWord

sobjWord.Text = strWord

strChar = Left$(sobjWord.Text, 1)

For Each objChar In mcolLettersInGrid

If objChar.Char = strChar Then

With objChar

sobjWord.AddLetter.Char, .GridX, .GridY

End With

GetWord <<<<<< what does this do in vb6?

End If

If sobjWord.IsComplete Then

GetWord = sobjWord

sobjWord = Nothing

Exit For

Else

sobjWord.RemoveLetter(objChar.GridX, objChar.GridY)

End If

Next

Else

objLastChar = sobjWord.Letter(intIndex:=sobjWord.FoundCharacters)

strChar = Mid$(sobjWord.Text, sobjWord.FoundCharacters + 1, 1)

For sdDirection = sdUp To sdUpRight

While objChar Is Nothing

objChar = NextLetter(objLastChar.GridX, objLastChar.GridY, sdDirection)

If sdDirection = sdUpRight Then

If objChar Is Nothing Then

sobjWord.RemoveLetter(objLastChar.GridX, objLastChar.GridY)

Exit Function

End If

Else

If objChar Is Nothing Then sdDirection = sdDirection + 1

End If

End While

If objChar.Char = strChar And Not sobjWord.IsLetterUsed(objChar) Then

With objChar

sobjWord.AddLetter.Char, .GridX, .GridY

End With

If Not sobjWord.IsComplete Then

GetWord()

End If

End If

If sobjWord.IsComplete Then Exit Function

If Not sobjWord.IsLetterUsed(objChar) Then

sobjWord.RemoveLetter(objChar.GridX, objChar.GridY)

End If

If sdDirection = sdUpRight Then

sobjWord.RemoveLetter(objLastChar.GridX, objLastChar.GridY)

End If

objChar = Nothing

Next

End If

End Function

sjunsk  Tuesday, December 01, 2009 4:54 AM

Hi sjunsk,

Based on the source code you posted,the GetWord function will be called repeatedly inside the GetWord function itself, which is so-called "Recursion Call".

GetWord <<<<<< what does this do in vb6?
-> It means calling GetWord function without anyargument. (Because the parameter is optional in the GetWord function according to the declaration: Public Function GetWord(Optional ByVal strWord As String) As iWord)

Suggestion:
In upgrated VB.NET code, change GetWord.Text() to: Call GetWord() or GetWord()


Best regards,

Martin Xie

MSDN Subscriber Support in Forum

If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Martin Xie - MSFT  22 hours 27 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Can't get Support.LoadResString to work in the Microsoft.VisualBasic.Compatibility.VB6 namespace
• VB6 doesn't load DirectX meshes under Vista
• Problems to install mdac 2.5 in windows vista to instal Vs Service Pack 6
• Using a DLL wrote in ASM into VB.NET
• output string in COM component made by vb.net
• how to make a vb6 app a childform of a .net application
• Win32 COM Clients Using .NET Objects
• COM interop using exe instead of dll
• Call C++ Interop function throws AccessViolation exception
• deploy VB6 app with .NET 2.0 instead of 3.5