在excel中声明vba中的unicode字符串 [英] declaring a unicode string in vba in excel

查看:527
本文介绍了在excel中声明vba中的unicode字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个将希腊字符转换为拉丁的替代()。



问题是,在声明


$
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

来源被解释为áâãäåæçéêëìíîïðñóôõöù

有什么办法在声明级别使用unicode?

解决方案

您可以尝试 StrConv

  StrConv αβγδεζηικλμνξοπρστθφω,vbUnicode)

资料来源: http://www.techonthenet.com/excel/formulas/strconv.php



另一个解决方案:



由于这个过程,你可以得到每个希腊字符(大写和大写):

  Sub x()
Dim i As Long

对于i = 913到969
与单元格(i - 912,1)
.Formula == dec2hex(&我& )
.Offset(,1).Value = ChrW $(i)
End with
Next i
End Sub

您可以创建一个数组来查找char。例如:



资料来源: http://www.excelforum.com/excel-programming/636544-adding -greek-letters.html



这是一个子建立你想要的字符串:

  Sub greekAlpha()
Dim sAlpha As String
Dim lLetter As Long

对于lLetter =& H3B1 To& ; H3C9
sAlpha = sAlpha& ChrW(lLetter)
下一个
End Sub


I am trying to create a substitute() that will convert greek characters to latin.

The problem is that after declaring

Dim Source As String
Source = "αβγδεζηικλμνξοπρστθφω"  

Source is interpreted as "áâãäåæçéêëìíîïðñóôõöù"
is there any way use unicode at declaration level?

解决方案

You can try StrConv:

StrConv("αβγδεζηικλμνξοπρστθφω", vbUnicode)

Source : http://www.techonthenet.com/excel/formulas/strconv.php

[EDIT] Another solution:

You can get every greek character (lower and upper case) thanks to this procedure:

Sub x()
    Dim i As Long

    For i = 913 To 969
        With Cells(i - 912, 1)
            .Formula = "=dec2hex(" & i & ")"
            .Offset(, 1).Value = ChrW$(i)
        End With
    Next i
End Sub

You can create an array to find the char for instance.

Source: http://www.excelforum.com/excel-programming/636544-adding-greek-letters.html

[EDIT 2] Here is a sub to build the string you wanted:

Sub greekAlpha()
Dim sAlpha As String
Dim lLetter As Long

For lLetter = &H3B1 To &H3C9
    sAlpha = sAlpha & ChrW(lLetter)
Next
End Sub

这篇关于在excel中声明vba中的unicode字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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