Convert Ascii string to decimal

  • Thread starter Thread starter friend
  • Start date Start date
friend said:
Is there any way to convert an ascii string to decimal.

Can you give us an example of an ASCII string and of the expected Decimal
value?


Armin
 
You mean something as

dim Ten = CDec("10")

Cor

for example I get the input from remote host something like this : "Ä"
or some other character "Ì" or "Œ"
I want to convert this character to decimal and check the bits.

please help me
 
Hi,

That is not a string that is a character

dim i = Ascw("Œ"c)

I hope this helps,

Cor


You mean something as

dim Ten = CDec("10")

Cor

for example I get the input from remote host something like this : "Ä"
or some other character "Ì" or "Œ"
I want to convert this character to decimal and check the bits.

please help me
 
friend said:
for example I get the input from remote host something like this : "Ä"
or some other character "Ì" or "Œ"

How do you receive the data?
I want to convert this character to decimal and check the bits.

You can not check bits because a decimal value is also a String. (If you
meant the Decimal type to store the character code, you would have chosen
the wrong type.)

If you receive an "Ä", it is _not_ ASCII. ASCII does not contain the German
"Umlaut". If you have a String, it's a Unicode string. You can convert it by
using

dim bytes as byte()

bytes = system.text.encoding.unicode.getbytes(yourString)

Then you can process the array of bytes.



Armin
 
You need to know exactly what numeric type the characters represent. It
could be unsigned integer, integer or floating point (as examples) and it
could be one of a variety of different sizes. Even if it's simple integer it
could be big-endian or little-endian, which affects the conversion.

Routines are available for almost any type of conversion, but there are some
built-in to .NET. See, for instance:

http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx

which works on an array of bytes (easily created from a string) but doesn't
include Decimal.
 
Hello all,

Is there any way to convert an ascii string to decimal.

Thanks to everyone

Decimal.Parse or Decimal.TryParse.

I prefere TryParse because it returns a boolean value to indicate success or
failure rather then throw an exception.
 
Decimal.Parse or Decimal.TryParse.

I prefere TryParse because it returns a boolean value to indicate successor
failure rather then throw an exception.

Thanks to all...I solved my problem...
 
Back
Top