Convert Ascii string to decimal

F

friend

Hello all,

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

Thanks to everyone
 
A

Armin Zingler

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
 
F

friend

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
 
C

Cor Ligthert[MVP]

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
 
A

Armin Zingler

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
 
J

James Hahn

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.
 
T

Tom Shelton

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.
 
F

friend

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...
 

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

Top