Simple Decimal-> String formatting problem

  • Thread starter Thread starter Saul
  • Start date Start date
S

Saul

Hi all,

I have what I think is a very simple problem but I seem to be struggling to
find an elegant solution to it.

I have a value inside a double variable, and I want to display this in a
textbox but format it to be "0.00"

eg

1 = "1.00"
10.5 = "10.50"
0.25 = "0.25"
0.3333 = "0.33"

I would normally use the format function, but it doesn't seem to be
supported in CF. I use VB, so if you can, please give code in VB. I'm fairly
sure this can be done in one line of code.

Thanks in advance,
Saul
 
This should work:

Dim val As Decimal = 1
Me.TextBox1.Text = val.ToString("0.00")
 
Tim,

It should, and it does, THANKS!!

I did not know you could put formatting at the end of the tostring, I'll
have to learn more about this.

Thanks again,
Saul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top