代码如下..我只想输入> < >= <= !这五个性符号.应该怎样判断呢?主函数调用下面的函数来判断..哪里有不对.请高手指教.
Public Function StrCheck1(ChkStr As Variant, ByRef ErrWord As String)
Dim wstr() As String
Dim i As Integer
StrCheck1 = True
ErrWord = ""
ReDim wstr(5)
wstr(0) = ">"
wstr(1) = "<"
wstr(2) = ">="
wstr(3) = "<="
wstr(4) = "!="
For i = LBound(wstr, 1) To UBound(wstr, 1)
If InStr(1, CStr(ChkStr), wstr(i)) = 0 Then
ErrWord = wstr(i) StrCheck1 = False
End If
Next iEnd Function
Public Function StrCheck1(ChkStr As Variant, ByRef ErrWord As String)
Dim wstr() As String
Dim i As Integer
StrCheck1 = True
ErrWord = ""
ReDim wstr(5)
wstr(0) = ">"
wstr(1) = "<"
wstr(2) = ">="
wstr(3) = "<="
wstr(4) = "!="
For i = LBound(wstr, 1) To UBound(wstr, 1)
If InStr(1, CStr(ChkStr), wstr(i)) = 0 Then
ErrWord = wstr(i) StrCheck1 = False
End If
Next iEnd Function
解决方案 »
- 改进计算器 下一步 对我很难对你很简单 来看看吧
- vb.net 水晶報表中圖片顯示問題
- 动态数组存储若干数如:a(0)=3 a(1)=4 a(2)=5 a(3)=8 将其形成字符串3-5/8?
- access连接数据库
- 请问如何写软件试用代码
- 部件fm2.0.dll问题
- vb如何实现类似PHOTOSHOP的滤镜功能,将滤镜文件放到指定目录就可以在程序中引用?
- 关于printer打印单据的问题?在线等待!
- 想 用vb做一个问卷调查系统,请各位支招。
- 对于网格控件,直接使用DataGrid绑定和使用MSHFlexGrid控件自已写代码填充究意哪个好?
- vb中如何实现上升沿和下降沿?
- 解背包问题,递归、回溯、穷举法那种算法比较好
Dim wstr() As String
Dim i As Integer
StrCheck1 = True
ErrWord = ""
ReDim wstr(5)
wstr(0) = ">"
wstr(1) = " <"
wstr(2) = ">="
wstr(3) = " <="
wstr(4) = "!="
For i = LBound(wstr, 1) To UBound(wstr, 1)
If InStr(1, CStr(ChkStr), wstr(i)) = 0 Then
ErrWord = wstr(i)
StrCheck1 = False
Exit For
End If
Next iEnd Function
'你代码要实现的功能是:
'-------判断chkstr中是否同时存在规定的5种字符,
'如存在则函数返回True,引用变量ErrWord返回“”,
'如果有不存在的,函数返回false,引用变量ErrWord返回首次未出现的字符
Public Function StrCheck1(ChkStr As Variant, ByRef ErrWord As String)
Dim wstr() As String '定义动态数组
Dim i As Integer '
StrCheck1 = True '先设定函数的默认返回值
ErrWord = "" '将引用来的外部变量置空
ReDim wstr(5) '给动态数组从新分配容量---大小为5
wstr(0) = ">" '赋值
wstr(1) = " <"
wstr(2) = ">="
wstr(3) = " <="
wstr(4) = "!="
For i = LBound(wstr, 1) To UBound(wstr, 1) ' 遍历动态数组数组wstr的第一维数据
If InStr(1, CStr(ChkStr), wstr(i)) = 0 Then
'判断对应数组中的值是否存在于chkstr中====》根据你此处的判断,要求输入的chkstr中一定要同时包含五个值!!
ErrWord = wstr(i) '首次检测到没有的放入errword
StrCheck1 = False '置错
Exit For '跳出
End If
Next iEnd Function
呵呵,我是新手,刚学VB不久.让大家见笑了.