Solved

System Settings and textboxes

Posted on 1999-01-18
3
144 Views
Last Modified: 2010-05-03
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 ??
0
Comment
Question by:ttrigo
3 Comments
 
LVL 1

Accepted Solution

by:
rondeauj earned 50 total points
ID: 1469289
1) STR is a VB keyword

2) try this:

 dim tempstring as string
 tempstring = format(text1.text,"#####.##")


0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469290
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,
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 1469291
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,

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now