トップページ(目次)

578.半角かどうか判定する

<実行前後>
 → 
Sub 半角かどうか判定する()
    
    対象文字列 = Range("A1")
    
    文字数 = Len(対象文字列)
    
    バイト数 = LenB(StrConv(対象文字列, vbFromUnicode))
    
    '半角のみの場合、文字数 = バイト数になる
    If 文字数 = バイト数 Then
        MsgBox "半角のみです"
    Else
        MsgBox "半角以外も入力されています"
    End If
    
End Sub

Copyright © 2021 https://excel3000.web.fc2.com/ All Rights Reserved.
    inserted by FC2 system