在 VBA 中检测文本语言 [英] Detect text language in VBA

查看:65
本文介绍了在 VBA 中检测文本语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PowerPoint 中有一个文本框,我用 Split 将它存储到一个数组中.有什么方法可以检测VBA中文本是什么语言?实际上只会有英文或中文文本,所以我想另一种解决方案是检测文本是否不是英文,或者是/不是 Unicode?

I have a textbox in PowerPoint which I store into an array with Split. Is there any way to detect what language the text is in VBA? There will actually only be English or Chinese text, so I guess an alternative solution would be to detect if the text is not English, or is/isn't Unicode?

推荐答案

应该可以通过检查其中一个字符是中文来实现的:

It should be possible by checking that one of the characters is Chinese:

Function IsChiness(text As String) As Boolean
  Dim c&, i&
  For i = 1 To Len(text)
    c = AscW(Mid$(text, i, 1))
    If c >= &H4E00& And c <= &H9FFF& Then
      IsChiness = True
      Exit Function
    End If
  Next
End Function

这篇关于在 VBA 中检测文本语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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