Solved

assigning 0 to a textbox problem

Posted on 2004-08-11
5
289 Views
Last Modified: 2010-05-02
I fill in a text box 9txt_textbox) with a variable (var_textbox)
using this function.

txt_textbox = Format(var_textbox, "####.#")

The variable var_textbox is declared as single.

Now my problem. If the variable is set to zero , than on the screen it comes up with an entry like

  .     That means a single dot is visible in the textbox.
How do I have to programme to show actuakky the 0 value?  Or I would not mind neither an empty textbox with no dot at all instead
0
Comment
Question by:themroc
5 Comments
 
LVL 2

Expert Comment

by:zULu
Comment Utility
if var_textbox=0 then
    txt_textbox = 0
else
    txt_textbox = Format(var_textbox, "####.#")
end if
that should do it
0
 
LVL 4

Accepted Solution

by:
hamood earned 100 total points
Comment Utility
Use this one
txt_textbox = FormatNumber(var_textbox, 1)

it will disply value like 0.0
0
 
LVL 6

Expert Comment

by:mmusante
Comment Utility
Try this ...

Format(var_textbox, "###0.#")

if you want '0.' or this

Format(var_textbox, "###0.0")

if you want '0.0'
0
 
LVL 19

Expert Comment

by:Shauli
Comment Utility
txt_textbox = IIF(var_textbox = 0, 0, FormatNumber(var_textbox, 1))

S
0
 

Author Comment

by:themroc
Comment Utility
I think hammod gave the most appropriate answer, this really solve the problem and because it is tied in a way to the country setting in fact it solves other issued I HAD TOO!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now