Format a Textbox String to the Correct Currency

Format a Textbox String to the Correct Currency

This code allows you to format a textbox string to the correct currency in SQL Server, independent of regional settings or the user input decimal symbol:

 Public Function FormatMoney(ByVal strValue As String) As String        '**This function fails if the user uses a digit grouping symbol and no decimal symbol.        '** Get the decimal symbol from the system        Dim DecS As String = Mid$(CStr(1.1), 2, 1)        '** Find the location of the first dot        Dim intDot As Integer = InStr(strValue, ".")        '** Find the location of the first comma        Dim intComma As Integer = InStr(strValue, ",")        '** Select your regional decimal sign        Select Case DecS            Case ","                '** Check to see if a dot or comma was used by the user                If intDot > intComma Then                    '** make sure only the decimal sign remains                    strValue = Replace(strValue, ",", "")                    strValue = Replace(strValue, ".", ",")                End If                '** round the value to 2 decimals                strValue = Decimal.Round(strValue, 2)                '** prepare the value for SQL server                strValue = Replace(strValue, ",", ".")            Case "."                If intComma > intDot Then                    '** make sure only the decimal sign remains                    strValue = Replace(strValue, ".", "")                    strValue = Replace(strValue, ",", ".")                End If                '** round the value to 2 decimals                strValue = Decimal.Round(strValue, 2)        End Select        Return strValue    End Function
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved