Link to home
Start Free TrialLog in
Avatar of ttrigo
ttrigo

asked on

System Settings and textboxes

if i do this command:
Str$ = text1.text
with the decimal numeric format of systems settings = "," it doesn't retrieve the right value.
How can i get it right ??
ASKER CERTIFIED SOLUTION
Avatar of rondeauj
rondeauj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of caraf_g
caraf_g

Even though Str is a VB Keyword you are allowed to Dim:
Dim Str$

Although I wouldn't recommend it precisely for that reason.

That aside, I do not understand what you are trying to do here:

Str$ = text1.text

I assume that text1 is a text box; in that case, the text property of text1 is a string type property anyway. So you're assigning the value of string text1.text to string Str$

The decimal numeric format of system settings doesn't come into the picture at all.

So, what exactly are you trying to do? Once I understand that, I will be able to sort out your problem for you.

Regards, etc,
Avatar of Éric Moreau
Try this function.

'pstrDecimal is a string containing the string representation of your number
Public Function FormatDecimalSQL(ByVal pstrDecimal As String) As String
Const kSep as string = ","
Dim intPos As Integer
   
    intPos = InStr(1, pstrDecimal, kSep)
    If intPos = 0 And Len(pstrDecimal) > 0 Then
        FormatDecimalSQL = pstrDecimal
    ElseIf Len(pstrDecimal) = 0 Then
        FormatDecimalSQL = "0"
    Else
        FormatDecimalSQL = Mid$(pstrDecimal, 1, intPos - 1) & _
                           "." & _
                           Mid$(pstrDecimal, intPos + Len(kSep))
    End If
End Function

Normally,