VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This function will take a string with a dollar sign anywhere and remove it. I use this function to

by David Koopman (11 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 28th October 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This function will take a string with a dollar sign anywhere and remove it. I use this function to update a value in a database that is

Rate This function will take a string with a dollar sign anywhere and remove it. I use this function to



    Dim strReplace As String
    
        strReplace = "$200"
        MsgBox StripDollarSign(strReplace)
    
End Sub


Private Function StripDollarSign(strOldString As String) As String

On Error GoTo StripDollarSignErr
'This function removes the dollar sign from fields in order to update
'the database. Fields are numeric in SQL.
        Dim Counter As Integer
        Dim I As Integer
        Dim strX As String
        Dim strUrl As String
        
        For I = 1 To Len(strOldString)
            strX = Mid(strOldString, I, 1)
            If strX = "$" Then
                Counter = Counter + 1
                    If Counter = 1 Then
                        I = I + 1
                        strX = Mid(strOldString, I, 1)
                            Do While strX <> ""
                                strX = Mid(strOldString, I, 1)
                                    If strX = "" Then
                                        Exit For
                                    End If
                                strUrl = strUrl & strX
                                I = I + 1
                            Loop
                    End If
            Else
                strUrl = strOldString
            End If
        Next
        'Set new string = function to return
        StripDollarSign = strUrl
        
StripDollarSignExit:
    Exit Function

StripDollarSignErr:
    App.StartLogging App.Path & "\Error.log", vbLogToFile
    App.LogEvent Err.Description, vbLogEventTypeError
    Resume StripDollarSignExit

End Function



Download this snippet    Add to My Saved Code

This function will take a string with a dollar sign anywhere and remove it. I use this function to Comments

No comments have been posted about This function will take a string with a dollar sign anywhere and remove it. I use this function to . Why not be the first to post a comment about This function will take a string with a dollar sign anywhere and remove it. I use this function to .

Post your comment

Subject:
Message:
0/1000 characters