Small Basic中文站-快乐编程

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 444|回复: 0

Sub EndSub的实例

[复制链接]
发表于 2017-6-28 13:22:16 | 显示全部楼层 |阅读模式
本帖最后由 鱼二六 于 2017-6-28 13:24 编辑

You can write subroutines anywhere in your program.  Statements not included in subroutines are treated as in main routine.  So you can write program as follows.
A() ' statement calls subroutine A
Sub A
EndSub
B() ' statement calls subroutine B
Sub B
EndSub

But to distinguish main and sub, main statements are better to be written in one place as following list.
A() ' statement calls subroutine A
B() ' statement calls subroutine B
Sub A
EndSub
Sub B
EndSub




实例3:
n = 5

Factorial()
TextWindow.WriteLine(n + "!=" + f)
Sub Factorial
  ' param n
  ' return f = n!
  f = 1
  For i = 2 To n
    f = f * i
  EndFor
EndSub

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|Small Basic中文站-快乐编程 ( 闽ICP备09051788号 |

GMT+8, 2019-12-12 15:50 , Processed in 0.240366 second(s), 10 queries , File On.

Powered by Discuz! X3.3

快速回复 返回顶部 返回列表