广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    在excle中怎样执行主过程和子过程?

    来源:网络收集  点击:  时间:2024-08-08
    【导读】:
    在excle中怎样执行主过程和子过程?方法/步骤1/8分步阅读

    打开excle软件,进入VBA的编程界面,打开其中一个模块进行编辑,事先做好了几个子过程和函数,GetUsername,GetFirst,GetLast,DisplayLastFirst

    2/8

    接着是设置主过程,也就是程序执行的入口,命名为username

    3/8

    然后定义变量

    Dim full As String, first As String, last As String

    4/8

    接着是调用子过程GetUsername。

    Call GetUsername(full)

    5/8

    再调用GetFirst,获得名字的第一个。

    first = GetFirst(full)

    6/8

    调用GetLast,获得名字的最后一个。

    last = GetLast(full)

    7/8

    最后调用DisplayLastFirst,用来输出名字。

    Call DisplayLastFirst(first, last)

    完整代码如下:

    Sub UserName() Dim full As String, first As String, last As String Call GetUsername(full) first = GetFirst(full) last = GetLast(full) Call DisplayLastFirst(first, last) End Sub

    Sub GetUsername(fullname As String) fullname = InputBox(请输入你的第一个名字和最后一个名字)

    End SubFunction GetFirst(fullname As String) Dim space As Integer space = InStr(fullname, ) GetFirst = Left(fullname, space - 1)

    End Function

    Function GetLast(fullname As String) Dim space As Integer space = InStr(fullname, ) GetLast = Right(fullname, Len(fullname) - space) End FunctionSub DisplayLastFirst(first, last) MsgBox first , last

    End Sub

    8/8

    最后运行这个程序。

    EXCLEVBA编程主过程子过程
    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1090864.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-07 00:59:49  耗时:0.027
    0.0275s