Welcome to Windows Help!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ASCII Convert

 
   Windows Help (Home) -> Microsoft Access RSS
Next:  Smartart Tools in Word  
Author Message
Sam

External


Since: Nov 24, 2008
Posts: 3



(Msg. 1) Posted: Tue Dec 22, 2009 9:23 am
Post subject: ASCII Convert
Archived from groups: microsoft>public>access (more info?)

I have sample values listed below in a field called AMT1.
002527}
0024763
002349Q
002052}
0019258
001645K
001237B
004567J


and I need to convert these values to the true number as exampled
below:

As an example the data below will convert a signed numeric value for a
specific field.

ï‚§ Sample AMT1 = 1237B
This is amount would need to be converted as 123.72

ï‚§ 2nd Sample AMT = 4567J
This is amount would need to be converted as 456.71- or (456.71)

I have a chart of the ascii character to the number value.

What would be the easiest way to convert these values?

Thanks for your help!!!!

 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Jeff Boyce

External


Since: Nov 26, 2008
Posts: 32



(Msg. 2) Posted: Tue Dec 22, 2009 10:43 am
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Sam

I'm not seeing the relationship ...

How does "B" become "2", but "J" become "1" (and cause the amount to become
negative)? Do you have a table of the conversions?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Sam

External


Since: Nov 24, 2008
Posts: 3



(Msg. 3) Posted: Tue Dec 22, 2009 10:51 am
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Thanks for your response, I have a table called ASCII SIGNED NUMERIC
FIELDS CONVERSION VALUES AND FORMULAS and the relationship is listed
below
Value Character

+0 {
+1 A
+2 B
+3 C
+4 D
+5 E
+6 F
+7 G
+8 H
+9 I

-0 }
-1 J
-2 K
-3 L
-4 M
-5 N
-6 O
-7 P
-8 Q
-9 R


On Dec 22, 12:43 pm, "Jeff Boyce" wrote:
> Sam
>
> I'm not seeing the relationship ...
>
> How does "B" become "2", but "J" become "1" (and cause the amount to become
> negative)?  Do you have a table of the conversions?
>
> More info, please...
>
> Regards
>
> Jeff Boyce
> Microsoft Access MVP
>
> --
> Disclaimer: This author may have received products and services mentioned
> in this post. Mention and/or description of a product or service herein
> does not constitute endorsement thereof.
>
> Any code or pseudocode included in this post is offered "as is", with no
> guarantee as to suitability.
>
> You can thank the FTC of the USA for making this disclaimer
> possible/necessary.
>
> "Sam" wrote in message
>

> I have sample values listed below in a field called AMT1.
> 002527}
> 0024763
> 002349Q
> 002052}
> 0019258
> 001645K
> 001237B
> 004567J
>
> and I need to convert these values to the true number as exampled
> below:
>
> As an example the data below will convert a signed numeric value for a
> specific field.
>
> ? Sample AMT1 = 1237B
> This is amount would need to be converted as 123.72
>
> ? 2nd Sample AMT = 4567J
> This is amount would need to be converted as 456.71- or (456.71)
>
> I have a chart of the ascii character to the number value.
>
> What would be the easiest way to convert these values?
>
> Thanks for your help!!!!
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
KARL DEWEY

External


Since: Jan 22, 2009
Posts: 16



(Msg. 4) Posted: Tue Dec 22, 2009 11:28 am
Post subject: RE: ASCII Convert
Archived from groups: per prev. post (more info?)

You did not post your conversion table so this does not accomadate the '}'
you have.
This would be shorter using your table.

Expr1: IIf(Right([AMT1],1) Between "J" And
"S",-1,1)*(Val([AMT1])/IIf(IsNumeric([AMT1]),100,10)+(IIf(Right([AMT1],1)
Between "A" And "I",(Asc(Right([AMT1],1))-64)/100,0))+(IIf(Right([AMT1],1)
Between "J" And "S",(Asc(Right([AMT1],1))-73)/100,0)))
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Sam

External


Since: Nov 24, 2008
Posts: 3



(Msg. 5) Posted: Tue Dec 22, 2009 11:28 am
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Dirk, this worked amazingly. THANKS SO MUCH


On Dec 22, 12:45 pm, "Dirk Goldgar"
wrote:
> A long time ago I wrote this function in response to a similar post:
>
> '------ start of code ------
> Function fncZonedToNumber( _
>                     ZonedValue As Variant, _
>                     Optional DecimalPlaces As Integer = 0) _
>             As Variant
>
>     Dim strValue As String
>     Dim strLast As String
>
>     If IsNull(ZonedValue) Then
>         fncZonedToNumber = Null
>     ElseIf VarType(ZonedValue) wrote in message
>

> I have sample values listed below in a field called AMT1.
> 002527}
> 0024763
> 002349Q
> 002052}
> 0019258
> 001645K
> 001237B
> 004567J
>
> and I need to convert these values to the true number as exampled
> below:
>
> As an example the data below will convert a signed numeric value for a
> specific field.
>
> ï‚§ Sample AMT1 = 1237B
> This is amount would need to be converted as 123.72
>
> ï‚§ 2nd Sample AMT = 4567J
> This is amount would need to be converted as 456.71- or (456.71)
>
> I have a chart of the ascii character to the number value.
>
> What would be the easiest way to convert these values?
>
> Thanks for your help!!!!
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
KARL DEWEY

External


Since: Jan 22, 2009
Posts: 16



(Msg. 6) Posted: Tue Dec 22, 2009 11:33 am
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Jeff,
If I remember this is an old number scheme used in a very old computer
system. I think the character series the '}' is in changes the decimal
position.
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Jeff Boyce

External


Since: Nov 26, 2008
Posts: 32



(Msg. 7) Posted: Tue Dec 22, 2009 12:01 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Hmph! And I thought I was old ...wrote in message

> Jeff,
> If I remember this is an old number scheme used in a very old computer
> system. I think the character series the '}' is in changes the decimal
> position.
>
> --
> Build a little, test a little.
>
>
> "Jeff Boyce" wrote:
>
>> Sam
>>
>> I'm not seeing the relationship ...
>>
>> How does "B" become "2", but "J" become "1" (and cause the amount to
>> become
>> negative)? Do you have a table of the conversions?
>>
>> More info, please...
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Access MVP
>>
>> --
>> Disclaimer: This author may have received products and services mentioned
>> in this post. Mention and/or description of a product or service herein
>> does not constitute endorsement thereof.
>>
>> Any code or pseudocode included in this post is offered "as is", with no
>> guarantee as to suitability.
>>
>> You can thank the FTC of the USA for making this disclaimer
>> possible/necessary.
>>
>>
>> "Sam" wrote in message
>
>> I have sample values listed below in a field called AMT1.
>> 002527}
>> 0024763
>> 002349Q
>> 002052}
>> 0019258
>> 001645K
>> 001237B
>> 004567J
>>
>>
>> and I need to convert these values to the true number as exampled
>> below:
>>
>> As an example the data below will convert a signed numeric value for a
>> specific field.
>>
>> ? Sample AMT1 = 1237B
>> This is amount would need to be converted as 123.72
>>
>> ? 2nd Sample AMT = 4567J
>> This is amount would need to be converted as 456.71- or (456.71)
>>
>> I have a chart of the ascii character to the number value.
>>
>> What would be the easiest way to convert these values?
>>
>> Thanks for your help!!!!
>>
>>
>>
>> .
>>
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Dirk Goldgar

External


Since: Dec 4, 2008
Posts: 33



(Msg. 8) Posted: Tue Dec 22, 2009 1:45 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

A long time ago I wrote this function in response to a similar post:

'------ start of code ------
Function fncZonedToNumber( _
ZonedValue As Variant, _
Optional DecimalPlaces As Integer = 0) _
As Variant

Dim strValue As String
Dim strLast As String

If IsNull(ZonedValue) Then
fncZonedToNumber = Null
ElseIf VarType(ZonedValue) <> vbString Then
fncZonedToNumber = CVErr(5) ' invalid argument
ElseIf Len(ZonedValue) = 0 Then
fncZonedToNumber = Null
Else
strLast = Right(ZonedValue, 1)
strValue = Left(ZonedValue, Len(ZonedValue) - 1)

If InStr(1, "0123456789", strLast, vbBinaryCompare) Then
strValue = strValue & strLast
ElseIf InStr(1, "ABCDEFGHI", strLast, vbBinaryCompare) Then
strValue = strValue & Chr(Asc(strLast) - 16)
ElseIf InStr(1, "JKLMNOPQR", strLast, vbBinaryCompare) Then
strValue = "-" & strValue & Chr(Asc(strLast) - 25)
ElseIf StrComp(strLast, "{", vbBinaryCompare) = 0 Then
strValue = strValue & "0"
ElseIf StrComp(strLast, "}", vbBinaryCompare) = 0 Then
strValue = "-" & strValue & "0"
Else
fncZonedToNumber = CVErr(5) ' invalid argument
Exit Function
End If

If DecimalPlaces = 0 Then
fncZonedToNumber = Val(strValue)
Else
fncZonedToNumber = Val(strValue) / (10 ^ DecimalPlaces)
End If

End If

End Function
'------ end of code ------

In your case, you would pass the value 2 for the DecimalPlaces argument:

?fncZonedToNumber("1237B", 2)
123.72
?fncZonedToNumber("4567J", 2)
-456.71
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Dirk Goldgar

External


Since: Dec 4, 2008
Posts: 33



(Msg. 9) Posted: Tue Dec 22, 2009 3:20 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

"KARL DEWEY" wrote in message

> If I remember this is an old number scheme used in a very old computer
> system. I think the character series the '}' is in changes the decimal
> position.

It's called Zoned Decimal, and it was used with the EBCDIC coding scheme.
In that scheme, the characters '0' to '9' were represented by hexadecimal
values F0 to F9. In Zoned Decimal coding, the digit in the last character
position of a signed number represented as text had its high-order four bits
overwritten with values other than F to indicate whether the number's value
was positive or negative.

C (last digit C0 through C9) = positive
D (last digit D0 through D9) = negative
F (last digit F0 through F9) = unsigned, assumed positive

Ah, it takes me back ...
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Jeff Boyce

External


Since: Nov 26, 2008
Posts: 32



(Msg. 10) Posted: Tue Dec 22, 2009 3:20 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

I understand the "how", now, but why?!

Sure seems like a lot of work just to add a minus sign...

Skippy

"Dirk Goldgar" wrote in message

> "KARL DEWEY" wrote in message
>
>> If I remember this is an old number scheme used in a very old computer
>> system. I think the character series the '}' is in changes the decimal
>> position.
>
> It's called Zoned Decimal, and it was used with the EBCDIC coding scheme.
> In that scheme, the characters '0' to '9' were represented by hexadecimal
> values F0 to F9. In Zoned Decimal coding, the digit in the last character
> position of a signed number represented as text had its high-order four
> bits overwritten with values other than F to indicate whether the number's
> value was positive or negative.
>
> C (last digit C0 through C9) = positive
> D (last digit D0 through D9) = negative
> F (last digit F0 through F9) = unsigned, assumed positive
>
> Ah, it takes me back ...
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: [URL="http://www.datagnostics.com/tips.html"]www.datagnostics.com/tips.html[/URL]
>
> (please reply to the newsgroup)
>
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
KARL DEWEY

External


Since: Jan 22, 2009
Posts: 16



(Msg. 11) Posted: Tue Dec 22, 2009 4:16 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

You might read this --
[URL="http://www.simotime.com/datazd01.htm"]http://www.simotime.com/datazd01.htm[/URL]
Zoned Decimal Format - Description and Discussion

This document will focus on a discussion of a numeric field (or data string)
format referred to as zoned decimal and is commonly used on an IBM Mainframe
System. This is the default numeric format for COBOL and may be explicitly
defined with the "USAGE IS DISPLAY" clause

Note: The items in this document are appropriate for applications that are
written in COBOL, Mainframe Assembler (HLASM) or PL/I. The IBM Mainframe
architecture drove many of the numeric formats that existed in the early ANSI
specifications for COBOL.and have been carried forward to the current COBOL
ANSI specifications.

The "SIGNED, ZONED-DECIMAL" format has caused problems for years for
mainframe programmers because the signed position of the field will display
as a character value of "A-I" for positive numbers and "J-R" for negative
numbers. It also allows for a positive and negative zero value that will
display as a "{" and "}", this is the curly brace symbol or x'C0' and x'D0'.

When converting this type of field from EBCDIC to ASCII the programmer is
presented with a number of confusing options and challenges. This document
will try to explain the options and help the programmer avoid the common
mistakes that are made during a conversion process.
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Jeff Boyce

External


Since: Nov 26, 2008
Posts: 32



(Msg. 12) Posted: Tue Dec 22, 2009 4:58 pm
Post subject: Re: ASCII Convert
Archived from groups: per prev. post (more info?)

Thanks for the reference, Karl.

It sounds like this format is a carry-over from dealing with the limitations
of the punch card.

Sorta like the story of why we cut the end off the ham before putting it
into the pan...wrote in message

> You might read this --
> [URL="http://www.simotime.com/datazd01.htm"]http://www.simotime.com/datazd01.htm[/URL]
> Zoned Decimal Format - Description and Discussion
>
> This document will focus on a discussion of a numeric field (or data
> string)
> format referred to as zoned decimal and is commonly used on an IBM
> Mainframe
> System. This is the default numeric format for COBOL and may be explicitly
> defined with the "USAGE IS DISPLAY" clause
>
> Note: The items in this document are appropriate for applications that are
> written in COBOL, Mainframe Assembler (HLASM) or PL/I. The IBM Mainframe
> architecture drove many of the numeric formats that existed in the early
> ANSI
> specifications for COBOL.and have been carried forward to the current
> COBOL
> ANSI specifications.
>
> The "SIGNED, ZONED-DECIMAL" format has caused problems for years for
> mainframe programmers because the signed position of the field will
> display
> as a character value of "A-I" for positive numbers and "J-R" for negative
> numbers. It also allows for a positive and negative zero value that will
> display as a "{" and "}", this is the curly brace symbol or x'C0' and
> x'D0'.
>
> When converting this type of field from EBCDIC to ASCII the programmer is
> presented with a number of confusing options and challenges. This document
> will try to explain the options and help the programmer avoid the common
> mistakes that are made during a conversion process.
>
> --
> Build a little, test a little.
>
>
> "Jeff Boyce" wrote:
>
>> I understand the "how", now, but why?!
>>
>> Sure seems like a lot of work just to add a minus sign...
>>
>> Skippy
>>
>> "Dirk Goldgar" wrote in message
>>
>> > "KARL DEWEY" wrote in message
>> >
>> >> If I remember this is an old number scheme used in a very old
>> >> computer
>> >> system. I think the character series the '}' is in changes the
>> >> decimal
>> >> position.
>> >
>> > It's called Zoned Decimal, and it was used with the EBCDIC coding
>> > scheme.
>> > In that scheme, the characters '0' to '9' were represented by
>> > hexadecimal
>> > values F0 to F9. In Zoned Decimal coding, the digit in the last
>> > character
>> > position of a signed number represented as text had its high-order four
>> > bits overwritten with values other than F to indicate whether the
>> > number's
>> > value was positive or negative.
>> >
>> > C (last digit C0 through C9) = positive
>> > D (last digit D0 through D9) = negative
>> > F (last digit F0 through F9) = unsigned, assumed positive
>> >
>> > Ah, it takes me back ...
>> >
>> > --
>> > Dirk Goldgar, MS Access MVP
>> > Access tips: [URL="http://www.datagnostics.com/tips.html"]www.datagnostics.com/tips.html[/URL]
>> >
>> > (please reply to the newsgroup)
>> >
>>
>>
>> .
>>
 >> Stay informed about: ASCII Convert 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
convert a number to an autonumber - Hello, I had an old Access database that had a bad design. I exported the data to a csv, cleaned it up, and imported it into a new database. During the import Access wouldn't let me change the field I use as a primary key which was an autonumber..

Convert data base - Saved my data base in 2007 in error. How can it get it back to the Vista verison of Access. I have lost most of the ribbon.

Microsoft Access 2003 cant convert the database to a desig.. - I am trying to make a database replicate and get this message "Microsoft Access cant convert the database to a design master" and therefore will not replicate can anyone shine a light

Microsoft Office - Can you update Microsoft office version 2003 to 2007 or do you have to buy the newer version

From access to word - Print - Hello, We open word letter from access with hiperlink code. . . .. . . Application.FollowHyperlink "h:\DRISHOT\" & lettername & ".doc" Is it possible to print the letter instead of open it ? How ? thank you
   Windows Help (Home) -> Microsoft Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]