通过哪个函数能够自动判断一个数据前面有没有字母,如果有就去掉数据前面的字母,输出数据;如果没有就直接输出数据。
举例:对于“C25200.0”,该函数能够自动判断出数据前面有字母并去掉字母(C),输出“25200.0";
对于“28520.0”,该函数能够自动判断数据前面没有字母,输出“28520.0”。
请大师不吝赐教,谢谢!!
[CODE]Function TickOutForwardingChars(inputStr As String) As String
Const MathStr = "0123456789"
Dim i As Integer, startPos As Long
startPos = 65536
For i = 1 To 10
startPos = IIf((InStr(inputStr, Mid(MathStr, i, 1)) < startPos) And (InStr(inputStr, Mid(MathStr, i, 1)) > 0), InStr(inputStr, Mid(MathStr, i, 1)), startPos)Next 'i
TickOutForwardingChars = Right(inputStr, Len(inputStr) - startPos + 1)
End Function[/CODE]
[CODE]Public Function TickOutForwardingChars(inputStr As String) As String
Const MathStr = "0 1 2 3 4 5 6 7 8 9"
Dim MathArr() As String
MathArr = Split(MathStr)
Dim i As Integer, startPos As Long
startPos = 65536
For i = 1 To 10
startPos = IIf((InStr(inputStr, MathArr(i)) < startPos) And (InStr(inputStr, MathArr(i)) > 0), InStr(inputStr, MathArr(i)), startPos)
Next 'i
TickOutForwardingChars = Right(inputStr, Len(inputStr) - startPos + 1)
End Function[/CODE]
[此贴子已经被作者于2007-9-15 14:37:23编辑过]