明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1622|回复: 1

[求助]字符检测方法!!

[复制链接]
发表于 2003-5-24 18:56 | 显示全部楼层 |阅读模式
您好:
    在vba中有 IsNumberic()函数检测变量是不是数值
但我需要一个能检验  所输的变量是不是 字符charactor的函数
或能实现此功能的办法

                                  请多多指点,谢谢!!
发表于 2003-5-24 22:56 | 显示全部楼层

写了个函数,只检测位于a-z和A-Z之间的字符。

Function IsCharacter(ByVal Expression As String) As Boolean
    IsCharacter = False
    Dim i As Integer
    Dim c As Long
   
    On Error GoTo ErrTrap
    If Expression = "" Then Exit Function
    IsCharacter = True
    For i = 1 To Len(Expression)
        c = Asc(Mid(Expression, i, 1))
        If Not ((c >= 65 And c <= 90) Or (c >= 97 And c <= 122)) Then
            IsCharacter = False
            Exit For
        End If
    Next
    Exit Function
   
ErrTrap:
    On Error GoTo 0
End Function
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-17 11:41 , Processed in 0.139340 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表