# Sub doesn't work, Why?

**URL:** <https://forum.xojo.com/t/sub-doesnt-work-why/59944>\
**Category:** Getting Started\
**Created:** [December 21, 2020, 8:23pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944 "2020-12-21T20:23:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Huett1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/dec6dc/32.png) [@Gary\_Huett1](https://forum.xojo.com/u/Gary_Huett1)\
**Post date:** [December 21, 2020, 8:23pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/1 "2020-12-21T20:23:29Z")

</div>

This is virtually right out of the book.  
Why am I getting these error messages?  
Xojo seems to be inherently buggy. e.g. if I change the format in an edit field, they add up differently.

 ![Screen Shot 2020-12-21 at 3.17.12 PM](https://forum.xojo.com/uploads/default/original/2X/c/c05876c0e56b4ee0f2fbc57fe86dc451299abddf.png)

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [December 21, 2020, 8:37pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/2 "2020-12-21T20:37:14Z")

</div>

a method is managed by xojo, remove the sub and end sub line.  
if you copy a method (via context menu over the name) then this source is complete in the clipboard.

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [December 21, 2020, 9:13pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/3 "2020-12-21T21:13:49Z")

</div>

What you are seeing is the external format of the code. The IDE provides the sub/end sub part for you.

“Sub DoublePlusTen(aNumber as Integer)”

means  
Type “DoublePlusTen” into the Method Name field  
Type “aNumber as Integer” into the Parameters field

“end sub” is provided by the IDE automatically. You don’t need to type it anywhere.

---

<div class="post-metadata">

**Author:** ![Gary\_Huett1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/g/dec6dc/32.png) [@Gary\_Huett1](https://forum.xojo.com/u/Gary_Huett1)\
**Post date:** [December 21, 2020, 9:17pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/4 "2020-12-21T21:17:23Z")

</div>

Thank you, I am familiar with that approach.  
I was curious why they present this as a coding example if it does not work.

---

<div class="post-metadata">

**Author:** ![Gilles\_Plante](https://forum.xojo.com/user_avatar/forum.xojo.com/gilles_plante/32/667_2.png) [@Gilles\_Plante](https://forum.xojo.com/u/Gilles_Plante)\
**Post date:** [December 21, 2020, 10:47pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/5 "2020-12-21T22:47:41Z")

</div>

> [@Gary\_Huett1](#):
>
> I was curious why they present this as a coding example if it does not work.

Xojo in many ways helps you in developing faster. What you see in the IDE is the body of the method DoublePlusTen. But the compiler is fetched the complete code, what you see in your screen capture.

Remove the first and last lines, it will compile fine. Then print the method, you will see the complete code !

---

<div class="post-metadata">

**Author:** ![Ivan\_Tellez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/a9a28c/32.png) [@Ivan\_Tellez](https://forum.xojo.com/u/Ivan_Tellez)\
**Post date:** [December 21, 2020, 11:09pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/6 "2020-12-21T23:09:52Z")

</div>

> [@Gilles\_Plante](#):
>
> But the compiler is fetched the complete code

\*The IDE

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 21, 2020, 11:33pm UTC](https://forum.xojo.com/t/sub-doesnt-work-why/59944/7 "2020-12-21T23:33:24Z")

</div>

Or highlight the working method in the project editor on the left, copy, then paste into something like a text editor. The result will be similar to the sample code in the docs.
