welcome to Qijie's Blog 薛其杰
代码
    Function GetInt(ByVal input As StringAs Integer
        
Dim reg As Regex = New Regex("^\d+$")
        
If Not reg.IsMatch(inputThen
            Console.WriteLine(
"input with invalide charactor")
            
Return -1
        
End If

        
Dim c As Char
        
Dim results As Integer = 0
        
For Each c In input.ToCharArray()
            results 
= results * 10
            results 
= results + Integer.Parse(c)
        
Next
        
Return results
    
End Function

 

posted on 2010-01-06 10:02  零点零一  阅读(373)  评论(0)    收藏  举报