Solved

Showing decimal format in Text Field  - VB Script

Posted on 2004-04-30
5
298 Views
Last Modified: 2010-05-02
Hi

The Test_Fields("TS_USER_09").Value  should show me as 3.0 when there is a 3

When we try it with a value as 3.1 it shows correctly as we want as 3.1

Is there any function where we can show a text field as 3.0 when it is only just a number like say 3 ?

 if (FieldName = "TS_STATUS") and (Test_Fields("TS_STATUS").Value = "Baselined")Then
         Test_Fields("TS_USER_09").IsReadOnly = False
                     verNum1  = CDbl(Test_Fields("TS_USER_09").Value)
                     verNum2  = Fix(verNum1)
                     verNum2  = verNum2 + 1.0

         Test_Fields("TS_USER_09").Value = cstr(verNum2)
         Test_Fields("TS_USER_09").IsReadOnly = True
       end if
0
Comment
Question by:Richards
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 100 total points
ID: 10959400
Test_Fields("TS_USER_09").Value = FormatNumber(verNum2, 1)

S
0
 
LVL 19

Expert Comment

by:Shauli
ID: 10959426
ps. where  the number 1 in the function FormatNumber("expression", 1) is the number of decimal places you want to display. If you set it to 2, then it would show 3.00, or 4,10 etc...

S
0
 
LVL 8

Expert Comment

by:bukko
ID: 10959589

Or:

Test_Fields("TS_USER_09").Value = Format( verNum2, "0.0" )

bukko
0
 
LVL 19

Expert Comment

by:Shauli
ID: 10959617
bukko,
That is not always true, as formatnumber takes the decimal separator from the system locale, because in some languages the decimal separator is a dot and in others its a comma. So going with 0.0 can be true only in those locales which use dot as a separator.

S
0
 
LVL 8

Expert Comment

by:bukko
ID: 10959759

So, what is truth anyhow?

bukko
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

808 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