Intro to Xojo eBook

Any one can help or advise?
I am going through the “Introduction to Programming with Xojo BY BRAD RHINE Spring 2014 Edition” (assume it is the latest).
No problems (no errors, all worked fine) till I got to chapter 8. The problem was with the Student Information project. Got most of it completed up to page 205.
The project so far executed as did as it supposed to.
As I continued page 206-208 to add methods, functions and properties for enrolling students I got 2 errors.

error 1 Too many arguments: got 1, expected 0.
at Button (Action) Line 7 (theStudent)

Dim theStudent As Student
Dim theCourse As Course
Dim newRow As String
theStudent = New Student(FirstNameField.Text, LastNameField.Text)
If CourseBox.CellTag(CourseBox.ListIndex,0) IsA Course Then
theCourse = Course(CourseBox.CellTag(CourseBox.ListIndex,0))
theCourse.EnrollStudent(theStudent)
newRow = theStudent.LastName + ", "
newRow = newRow + theStudent.FirstName
StudentBox.AddRow(newRow)
End If

error 2 This item does not exist (s)
at Course Method EnrollStudent

Me.EnrolledStudents.Append(s)

I have checked for typos etc. again and again but unable to find anything I type wrong
if it is possible to download a fully working project it may be easier for me (beginner) to pick up the problem.
I am using Xojo 2015 v2.2 on windows 8.1
Could there be any errors in this 2014 eBook?
Is there un update to this eBook?
Any assistance is much appreciated.

The first error sounds like the method EnrollStudent of the course class does not expect any parameters. From your code, it looks like it should. Is there a property of class student in the declaration of this method? I guess it should be named s because that’s what the second error points to.

Chris,

do not read Xojo’s error messages “to the letter”. Sometimes the answer is elsewhere.

My advice:
Take a deep breath,
Drink a glass of your prefered liquid (no alcohol),
Maybe Copy / Paste the error text and the “offending” line, resize them to some pixels greater,

and, at last, take your time watching carefully the offending code line. Especially, comma, parents, brackets, etc.

If this does not works, share the project (here you can do that) and probably someone will come with the answer.

Regards.

Thank You Ulrich and Emile,
Being a beginner It was a good lesson not expect spoon-fed instructions but understand what I was doing as I was building the app and reading carefully.
This is what the eBook instruction was:

  1. Add a method to your Course class called “EnrollStudent”.
    This method takes one parameter: S As Student. This method’s job is adding the
    provided student to the EnrolledStudents array.

  2. Add this code to EnrollStudent:
    Me.EnrolledStudents.Append(S)

I forgot to put the parameter S As Student, I took is as an explanation not an instruction.

Works OK now, I was almost going blind with my tears.
I think I am going to take another drink now (no Alcohol) I am keen to finish the app.
Thanks again for setting your time to give me a solution

Glad you found it! Emile is right, the Compiler errors can sometimes be misleading.

I have found this kind of error (number of parameters does not match) to be one of the correct ones – if you encounter it, count the properties you pass to a method and see if their number matches the number of parameters you declared in the method.

You will surely encounter a sometimes misleading error like Emile mentioned which is “there is more than one method by that name and it is not sure which one you mean” (not literally). This can pop up even when there is only one method of this name in your class and then should be read as “You pass a wrong kind of parameter”.

Thanks Ulrich,

This project (chapter) introduced a number of Classes, Methods and properties, for a beginner I will need more exercises to get a grasp of their behaviour and the points you and Emile provided will help to better understand them.

Hi!

Sorry to tag this thread but I have same issue here but I did not forgot to put the parameter s as student.
Here the thing This is what the eBook instruction was:

  1. Add a method to your Course class called “EnrollStudent”.
    This method takes one parameter: s As Student. This method’s job is adding the
    provided student to the EnrolledStudents array.

  2. Add this code to EnrollStudent:
    Me.EnrolledStudents.Append(s)

and then I have this message

Course.EnrollStudent, line 1 Type "Student" has no member named "Append" me.EnrolledStudents.Append(s)
how this type can not have his append? what should I do?

Thanks in advance
Kind regards,
Anthony

Did you forget the parenthesis when you created the EnrolledStudents property in the IDE? If so, you did not create an array but a simple Student property which of course has no append method.

Hi again

after googling I have spotted that is issue comes often . and use one the trick to fix it
I have set instead of this code
Me.EnrolledStudents.Append(s)
this code find on xojo forum

Sub EnrollStudent(s As Student) Me.EnrolledStudents.Append(s) End Sub
But this is not ok for me why is it different as in the book? is someone can tell what is going on here?

Thanks in advance

here the link of my project
link text
this is part of "8.5 Methods and functions in Classes) page 134

Anthony,

did you dowload the file there: https://www.xojo.com/resources/learn.php ?
(that is a revision of the 2014 edition: 3rd edition, 2016…).

Have you checked the pdf version (in case there is a difference) ?

Did you load the shared project ?
Get an eye in the Project folder Chapter 8 ?

Dear Emile

Thanks a lot for the hint. After compairing the 2 projects I have spotted that I have mis writted EnrolledStudents()

Everything is fine now

Thanks again

Copy / Paste was not working ?
Sorry.