Me again. Still struggling with the introduction to programming
Did this:

  1. Add a new method called “GetSelectedFont” to Window1.

Added to method:

Dim currentFont As String
If FontListBox.ListIndex <> - 1 Then
currentFont = FontListBox.List(FontListBox.ListIndex)
currentFont = “”
End If
Return currentFont

Made a PushButton FontButton and added this code to Action event

Dim fontName As String
fontName = GetSelectedFont
MsgBox "You have selected " + fontName

Run gives errors:

This method doesn’t return a value
fontName = GetSelectedFont

Type mismatch error. Expected String, but got Int32
fontName - GetSelectedFont

You cannot return a value because this method has not defined a return type
Return currentFont


You need to define the return type in the properties window for the method not within the method It is the Return Type field in the properties window for the method.

Total newbie here.

Where its the “properties window for the method”. That doesn’t seem to be explained in what I have read so far.

Look at the section on Methods link text

Should look like this in the inspector. Usually over on right towards top

You will need to put String into the Return Type field

That solved it, but I never would have guessed that these few words: “but its Return Type should be String”’ should have led me to the properties inspector where it would be necessary to set a return type. It strikes me as odd this would not be done with code.

Lesson learned.