?
Solved

Showing decimal format in Text Field  - VB Script

Posted on 2004-04-30
5
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 400 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 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