Number Format..

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Hi,

I am trying to format a number to the following, "10" to "10." using,
Printline(1, format(10, "###.###)) naturally this does not achieve the
desired result, I know if I do this, Printline(1, format(10, "###.0##)) I
get this "10.0" but I do not need the trailing "0" any ideas on how to get
from this "10" to this "10."?

Thanks,

Gary
 
You only want to add a period to the end of your number
console.writeline(10 & ".")
????
You want it formatted with trailing zeros?
Console.WriteLine(FormatNumber(10, 2))
 
* "Jared said:
You only want to add a period to the end of your number
console.writeline(10 & ".")

But what if the number is variable and can be 10, 10.2, ...?
 
What is a variable?

Seems Herfried doesn't like me very much, he's been pretty picky about my
postings.
I would still appriciate any help from you, Thanks!
 
I have posted another way of maybe tackling the problem I have (see top of
subject listing)

Gary
 
Gary said:
Hi,

I am trying to format a number to the following, "10" to "10." using,
Printline(1, format(10, "###.###)) naturally this does not achieve the
desired result, I know if I do this, Printline(1, format(10, "###.0##)) I
get this "10.0" but I do not need the trailing "0" any ideas on how to get
from this "10" to this "10."?

Thanks,

Gary

Gary:
Use the FormatNumber function...

From the Visual Basic Language Reference

Dim myNumber As Integer = 45600
Dim myString As String
' Returns "45,600.00".
myString = FormatNumber(myNumber, 2, , ,TriState.True)

Good luck...

A Hirsi
 
Jared said:
What is a variable?

Seems Herfried doesn't like me very much, he's been pretty picky about my
postings.
I would still appriciate any help from you, Thanks!


Jared:
A variable is a temporary storage location whose value changes (varies).
dim myVar as integer

myVar = 10
myVar = 1000

There are also constants and many other abstract data types.


Relax.
I don't think anyone is picky with you. No one has monopoly to knowledge.
Read and learn as much as you can and be prepared to take each posting
as a learning opportunity.

Hirsi
 
* "Jared said:
What is a variable?

I only wanted to add that your method will fail when used with a number
already containing a decimal point.
Seems Herfried doesn't like me very much, he's been pretty picky about my
postings.

No... That's not true...

:-)
 
* "Brian said:
Try this:

Dim str As String
Dim num As Int32 = 10
str = num.ToString("#" & "\.")

This will work with integers, but it won't work with numbers like 2.3.
 
* "Brian said:
Yeah, I know that Herfried. That's why I used an Int32
and not a double.

Just a little addition: I don't know the semantics of the ".", but if
it should be a decimal point, then I would not hardcode it. For example
on German systems, we use "," as separator.
 
Hi Herfried,

I saw this sentence now twice from you, I think it is better to change it a
little bit if you use it again,
Just a little addition: I don't know the semantics of the ".", but if
it should be a decimal point, then I would not hardcode it. For example
on German systems, we use "," as separator.

In something as For example on the European Continent (but not only there)
we use "," as separator.

I think that is a little bit more international, now it looks something as
if only a minority as the German speaking people are using it.

:-)

Cor
 
* "Cor said:
I saw this sentence now twice from you, I think it is better to change it a
little bit if you use it again,


In something as For example on the European Continent (but not only there)
we use "," as separator.

I was not sure if all/most contries on the European Continent use this
convention.
 
Back
Top