从指定索引处的字符串获取字符 [英] Getting char from string at specified index

查看:46
本文介绍了从指定索引处的字符串获取字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如前所述,如何从 VBA (Visual Basic for Applications) 中指定索引处的字符串中获取字符?我在 Google 上搜索过,但这些都不起作用:

As stated how to get char from string at specified index in VBA (Visual Basic for Applications)? I searched Google and these do not work:

s(index) ,s.Chars(index),s,Characters(index)

那么如何获取指定索引处的字符?

So how to get char at specified index?

推荐答案

如果 s 是你的字符串,那么你可以这样做:

If s is your string than you could do it this way:

Mid(s, index, 1)

根据问题下方的评论进行编辑.

看来您需要一些不同的方法,这应该更容易.试试这样:

It seems that you need a bit different approach which should be easier. Try in this way:

Dim character As String 'Integer if for numbers
's = ActiveDocument.Content.Text - we don't need it
character = Activedocument.Characters(index)

这篇关于从指定索引处的字符串获取字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆