0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AccessのVBAで文字列の全角or半角変換

Last updated at Posted at 2023-05-19

全角に変換

StrConv("文字列", vbWide)

半角に変換

StrConv("文字列", vbNarrow)

全角変換の動作確認用

  • この文字ってちゃんと全角変換される?
  • 全角変換されたらどんな文字になる?

を確認したい時用。

Dim dic_ As New Scripting.Dictionary
dic_.Add "'", Null
dic_.Add "?", Null
dic_.Add "*", Null
dic_.Add "#", Null
dic_.Add "\", Null
dic_.Add ",", Null
dic_.Add "%", Null
dic_.Add """", Null
dic_.Add "&", Null
dic_.Add "=", Null
dic_.Add "{", Null
dic_.Add "}", Null
dic_.Add "(", Null
dic_.Add ")", Null
dic_.Add "[", Null
dic_.Add "]", Null
dic_.Add ";", Null
dic_.Add "~", Null
dic_.Add "|", Null
dic_.Add "$", Null
dic_.Add "!", Null
dic_.Add "<", Null
dic_.Add ">", Null
dic_.Add "/", Null
dic_.Add "-", Null
dic_.Add "ー", Null
dic_.Add "一", Null

Dim key_ As Variant
For Each key_ In dic_
    Debug.Print key_ '変換前。
    Debug.Print StrConv(key_, vbWide) '変換後。
    Debug.Print ""
Next

半角変換の動作確認用

  • この文字ってちゃんと半角変換される?
  • 半角変換されたらどんな文字になる?

を確認したい時用。

Dim dic_ As New Scripting.Dictionary
dic_.Add "'", Null
dic_.Add "?", Null
dic_.Add "*", Null
dic_.Add "#", Null
dic_.Add "¥", Null
dic_.Add ",", Null
dic_.Add "%", Null
dic_.Add """, Null
dic_.Add "&", Null
dic_.Add "=", Null
dic_.Add "{", Null
dic_.Add "}", Null
dic_.Add "(", Null
dic_.Add ")", Null
dic_.Add "[", Null
dic_.Add "]", Null
dic_.Add ";", Null
dic_.Add "~", Null
dic_.Add "|", Null
dic_.Add "$", Null
dic_.Add "!", Null
dic_.Add "<", Null
dic_.Add ">", Null
dic_.Add "/", Null
dic_.Add "-", Null
dic_.Add "ー", Null
dic_.Add "一", Null

Dim key_ As Variant
For Each key_ In dic_
    Debug.Print key_ '変換前。
    Debug.Print StrConv(key_, vbNarrow) '変換後。
    Debug.Print ""
Next

参考サイトさん

バージョン

Windows 10 Pro 22H2 19045.2965
Microsoft Access for Microsoft 365 MSO (バージョン 2304 ビルド 16.0.16327.20200) 32 ビット

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?