VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert a String to an Integer

by Dan Walter (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 7th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Convert a String to an Integer

Rate Convert a String to an Integer



    Dim temp, ch As String
    Dim i, mult As Integer
    
    temp = s
    i = 0
    mult = 1
    
    While Len(temp) <> 0
        ch = Right(temp, 1)
        i = i + mult * (Asc(ch) - Asc("0"))
        mult = mult * 10
        temp = Left(temp, Len(temp) - 1)
    Wend
    
    Str2Int = i
End Function


Download this snippet    Add to My Saved Code

Convert a String to an Integer Comments

No comments have been posted about Convert a String to an Integer. Why not be the first to post a comment about Convert a String to an Integer.

Post your comment

Subject:
Message:
0/1000 characters