Tutorial Example ToDoList not working

Im working my ay through the Introduction to programming with XOJO Tutorial and a having problem getting it to work. When I add a row it never shows up in the ListBox.

here is the code I’m using:

Method UpdateToDoListBox
For Each row As String in ToDoList
ToDoListBox.AddRow(row)
Next

Control AddButton Pressed
ToDoListBox.AddRow(ToDoField.Text) //add user text to array
UpdateToDoListBox //update display
ToDoField.Text = “” // clear ToDoField

Can someone please tel lme what I may be doing wrong?

PLease Note. Im using the AddRow in the method because Add throws an error. I know AddRow was deprecated in a prior release but the program wont compile error free without it.

Any insights you can provide will be appreciated.

Thanks,

Del Thompson

Shouldn’t that be ToDoList.Add(ToDoField.Text)

UpdateToDoListBox loads from ToDoList, but you’re not putting anything into ToDoList.

1 Like

As Tim points out, the tutorial has this code for the AddButton Pressed event:

ToDoList.AddRow(ToDoField.Text) 
UpdateToDoListBox 
ToDoField.Text = ""

Thank you! I was going cross eyed trying to find the problem. My one queston is, why do we need a property (TodDoList) defined when all of the controls are defined within the same page?

It’s an example of modular programming. Only one function populates the listbox. That allows you to swap out the listbox for some other presentation without having to change a bunch of code. Granted, in this simple example, it’s overkill.

Are you saying I could put code into the property ToDoList? Could you how me some example code Please? I’m having trouble visualizing it.

Thanks,
Del

Do you load / check the ToDoList.xojo_binary_project example ?

No, that’s not what I’m saying. It’s modular in that everybody just stuffs stuff into ToDoList and then calls UpdateToDoListBox (which should really be called DisplayToDoList). The code in UpdateToDoListBox can be modified as needed and the rest of the program is unaffected.

Del: are-you OK ?

Thanks. I understand that now.as I go along I will probably see the value in it.

Del

Doing fine. Thanks for asking.

Del

Yes, I did. MY eyes just missed that crucial difference. Wish there was an easy way to extract all the source code from an app. then one could compare for differences.

I can strongly recommend Arbed for this purpose.

Thanks, Ill check it out.

Del

To get the whole project code (and more), for reading purposes, you can:

Load the ToDo project,
Click in App
Select Print in the File Menu
Save as PDF (works on Windows 8.1 and later / MacOS).
Load the pdf with your pdf reader and you’re done !

I’m running on the latest version of Windows 10 version 1904.746. IM using XOJO 2020r1. All I get is one page output:
Project: ToDoList
Date: Sunday, January 17, 2021 5:31:47 PM
App
Class App
Inherits WebApplication
End Class

I need to be in XJO to do this correct?

Del

OK, so, unselect everything in the Navigation pane * and print it again.

Oldsters usually have troubles with memory.

Sorry.

  • Apparently, you print the selected item(s) from the Navigation Pane.
    Also: if you go to the Preferences, there is an option to print the window(s) too. Check by yourself.

usually you would use a class with functionality such as load,save,add,remove,search,tolistbox.

Thanks Emile, Your second suggestion worked great! Just a Note: You know Robert Browning is given credit for the phrase “Grow old along with me! The best is yet to be, the last of life, for which the first was made.”

Personally, I think he was either delusional or high on something. I’ve found that memory may be the first, but not the last to go! Seize the day! Of course I’m sure there are those who would say I’m not old enough to make such observations!
Del
Del

1 Like