字符串转整数字函数

代码
    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
原文地址:https://www.cnblogs.com/qixue/p/1640135.html