VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
233 stars 16 forks source link

The button does not work ... #26

Closed boa2145 closed 1 year ago

boa2145 commented 1 year ago

Hello Mohammad, unfortunately I have to give you a note again. After your last update 2.8.4.3 the button does not work. I also run the program on Small Basic's IDE and there the button worked. I enclose the listing. Please, have a look at it. Regards ... Gregor

Screenshot (444)

VBAndCs commented 1 year ago

@boa2145 Please post the code so I can try it. But first: Is this a SB code that you are trying to run in sVB? The last sVB update has nothing to do with the Button class, nor the compiler. The change is in the Sound class only. sVB has breaking changes because of the new local variable domain, so some SB codes do not work in sVB. If this is the case, you should review the code logic and trace the variables to see how the local domain affects them. And I advise in such case to get rid of global variables and use parameters and functions return values. Thanks.

boa2145 commented 1 year ago

Hello Mohammad,

this program I first run in SB. In sVB I removed the initializing sub, but not the body (only Sub and EndSub) because of the global variables. Another problem is that I cannot use parameters in event handlers like TickSub(). I looked over the listing again and was not able to find the reason why the button does not work.

Regards ... Gregor

Screenshot (445)

VBAndCs commented 1 year ago

@boa2145 For starters, there is no ball image: BallImage = ImageList.LoadImage(Program.Directory + "\ball.gif") so, you will see nothing.

boa2145 commented 1 year ago

In my directory of the sb-file there is the gif-file "ball.gif", too. After starting the program I see a window with a button and the ball. It happens nothing after clicking on the button "Start". In SB there is an action after clicking on the button "Start". The ball is moving to the bottom and disapears.

Screenshot (446)

VBAndCs commented 1 year ago

@boa2145 Change:

Controls.ButtonClicked = ButtonClickedSub

to:

TimerButton.OnClick = ButtonClickedSub

I updateed the SB controls to use the new sVB controls. I don't remember to disable the old controls events, but I will review it for backward combatibility.

VBAndCs commented 1 year ago

@boa2145 I figured it out. When I updated the GW controls, I changed its key, for example, button1 would be graphicswindow.button1, but I didn't update the old ButtonClicked and TextTyped events to deal with such change. I've fixed this issue, but it will be available in the next sVB version. Until then, you can use the OnClick and OnTextChanged events via the button and textbox names. Thanks.

boa2145 commented 1 year ago

I wrote the whole program on sVB again 5 minutes ago, but it didn't work. Puuh!!!

I then changed it into "TimerButton.OnClick = ButtonClickedSub" and the program is working now. I have to write down your hints: "OnClick" and "OnTextChanged" events. Thanks for your help!