字符串操作
来源:百度文库 编辑:神马文学网 时间:2024/05/03 10:05:25
'************************************
'函数名: DataLength_Limit()
'参数 : obj :需处理的TEXTBOX对象
'
'返回值: 无
'
'说明 : 处理中文字符长度,限制输入byte数超过Text.MaxLength的中文字符
'************************************
Dim iLenUnicode As Integer
Dim i As Integer
Dim MaxLen As Integer
Dim sText As String
Dim j As Integer
j = obj.SelStart
sText = obj.Text
MaxLen = obj.MaxLength
If sText = "" Or MaxLen = 0 Then
Exit Sub
End If
iLenUnicode = Len(sText)
For i = 1 To iLenUnicode
If lstrlen(sText) > MaxLen Then
iLenUnicode = iLenUnicode - 1
sText = Left(sText, iLenUnicode)
Else
Exit For
End If
Next i
obj.Text = sText
obj.SelStart = j
End Sub '************************************
'函数名: NumKeyPress()
'参数 : obj :需处理的TEXTBOX对象
' Keyascii:需处理的ascii字符
' IntPlaces:最大整数位
' DecPlaces:最大小数位
'返回值: 数字字符
'
'说明 : 限制输入非数字字符,确保输入的为允许有效数字
'************************************Public Function NumKeyPress(obj As TextBox, KeyAscii As Integer, IntPlaces As Integer, DecPlaces As Integer) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim ilen As Integer NumKeyPress = KeyAscii i = obj.SelStart
j = InStr(obj.Text, ".")
k = obj.SelLength
ilen = Len(obj.Text) If KeyAscii = vbKeyBack Then
If k = 0 Then
If i = j Then
If ilen - 1 > IntPlaces Then
NumKeyPress = 0
End If
End If
Else
If InStr(obj.SelText, ".") > 0 Then
If ilen - k > IntPlaces Then
NumKeyPress = 0
End If
End If
End If End If
If KeyAscii >= 33 Then
If (KeyAscii < vbKey0 Or KeyAscii > vbKey9) And KeyAscii <> 46 Then
NumKeyPress = 0
Else
If KeyAscii = 46 Then
If InStr(obj.Text, ".") > 0 Then
NumKeyPress = 0
End If
Else
If j > 0 Then
If i >= j And (ilen - j) >= DecPlaces Then
NumKeyPress = 0
ElseIf i < j And j >= IntPlaces + 1 Then
NumKeyPress = 0
End If
Else
If ilen >= IntPlaces Then
NumKeyPress = 0
End If
End If
End If
End If
End IfEnd Function
'************************************
'函数名: NumKeyDown()
'参数 : obj :需处理的TEXTBOX对象
' KeyCode:需处理的KeyCode字符
' IntPlaces:最大整数位
' DecPlaces:最大小数位
'返回值: 数字字符
'
'说明 : 限制输入非数字字符,确保输入的为允许有效数字,主要响应“Delete”健
'************************************Public Function NumKeyDown(obj As TextBox, KeyCode As Integer, IntPlaces As Integer, DecPlaces As Integer) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim ilen As Integer NumKeyDown = KeyCode i = obj.SelStart
j = InStr(obj.Text, ".")
k = obj.SelLength
ilen = Len(obj.Text) If KeyCode = 46 Then
If k = 0 Then
If i + 1 = j Then
If ilen - 1 > IntPlaces Then
NumKeyDown = 0
End If
End If
Else
If InStr(obj.SelText, ".") > 0 Then
If ilen - k > IntPlaces Then
NumKeyDown = 0
End If
End If
End If End If
End Function
'************************************
'函数名: pbCheckChar
'参数 : intKeyascii:需处理的Keyascii字符
''返回值: 数字字符
'
'说明 : 限制输入字符,确保输入的为允许字符
'************************************Public Function pbCheckChar(intKeyascii As Integer) As Integer
If intKeyascii = 37 Or intKeyascii = 34 Or intKeyascii = 39 Or intKeyascii = 63 Then
pbCheckChar = 0
Else
pbCheckChar = 1
End If
End Function
字符串操作
字符串操作
用 javascript 操作字符串
用 JavaScript 操作字符串
python字符串操作
EL表达式对字符串的操作
python字符串操作 - Pipeline - 博客园
shell编程范例之字符串操作 - wuye_chinaunix
Loadrunner脚本编程(4)-数据类型操作和字符串操作
C语言中操作字符串的一些函数源码
字符串以及内存操作相关函数 - wuliming - CSDNBlog
C字符串操作函数 - Wirlfly‘s Blog - linux,unix,开源世界,生活感触
C语言中操作字符串的一些函数源代码 - C/C++ - 编程开发 - 破釜沉舟: 源码下载...
字符串处理
字符串分割
字符串hash算法比较|字符串,hash,算法
字符串函数大全
KMP字符串模式匹配
Delphi字符串函数大全
VC中字符串换行
VB.NET字符串函数
Delphi字符串函数大全
Delphi字符串函数
Sybase字符串函数