473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Ascii Values Of String

hi all

i have a string
<cr><lf>999,1.52,32.85,5.91,15.81,1.39,26.17,15.75 ,12.3
want to calculate its ASCII values sum which is equal to 2411.How can i calculate ascii sum of all the string values.

thanks in advance
Oct 18 '06 #1
1 4155
Killer42
8,435 Expert 8TB
hi all

i have a string
<cr><lf>999,1.52,32.85,5.91,15.81,1.39,26.17,15.75 ,12.3
want to calculate its ASCII values sum which is equal to 2411.How can i calculate ascii sum of all the string values.

thanks in advance
For a start, how are you counting? I tried it and got either 2367 or 3011, depending on whether I converted the "<cr><lf>" to carriage return (13) and linefeed (10) characters or not. Are you skipping the commas? Do you have trailing blanks that are included in the count?

Um...

Ok, I tried adding up the values of the actual numbers (first 999, then 1.52, and so on) and got 1110.7. So I still don't get it.
If it's any help, here's the routine I wrote to try it out. This was under VB6, and I just created a new project with one form.
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. DefLng A-Z
  3. Private Sub Form_Click()
  4.   Dim s As String
  5.   Dim TempNum As String, Char As String * 1
  6.   Dim I As Long, T As Long, T2 As Single
  7.  
  8.   's = vbCrLf & "999,1.52,32.85,5.91,15.81,1.39,26.17,15.75,12.3"
  9.   s = "<cr><lf>999,1.52,32.85,5.91,15.81,1.39,26.17,15.75,12.3"
  10.   For I = 1 To Len(s)
  11.     Char = Mid$(s, I, 1)
  12.     T = T + Asc(Char)
  13.     Debug.Print Asc(Char), T
  14.   Next
  15.   Debug.Print "Method 1: "; T
  16.  
  17.   For I = 1 To Len(s)
  18.     Char = Mid$(s, I, 1)
  19.     Select Case Char
  20.       Case "0" To "9", "."
  21.         TempNum = TempNum & Char
  22.       Case Else
  23.         T2 = T2 + Val(TempNum)
  24.         Debug.Print TempNum, T2
  25.         TempNum = ""
  26.     End Select
  27.   Next
  28.   T2 = T2 + Val(TempNum)
  29.   Debug.Print "Method 2: "; T2
  30. End Sub
Here's what it displayed...
Expand|Select|Wrap|Line Numbers
  1.  49            2864 
  2.  50            2914 
  3.  46            2960 
  4.  51            3011 
  5. Method 1:  3011 
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. 999            999 
  15. 1.52           1000.52 
  16. 32.85          1033.37 
  17. 5.91           1039.28 
  18. 15.81          1055.09 
  19. 1.39           1056.48 
  20. 26.17          1082.65 
  21. 15.75          1098.4 
  22. Method 2:  1110.7 
  23.  
Oct 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: b.stewart | last post by:
I have only been using C++ for a few afternoons and i still get confused at nearly every line i type so maybe someone here can help me. Im trying to write a small program that can change a...
8
by: Nik Martin | last post by:
If I receive a message from the .net sockets class, it's a byte array. The original message is an ASCII string,like "70,70,70,70,70,0,0,0,0". The commas here represent individual bytes. The 70's...
1
by: Kermit Piper | last post by:
Hello, I have a function that lets me convert one character and throw an alert with the corresponding ASCII value, but what I am having trouble with is applying it to a text box. What I'm trying...
7
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value....
18
by: John | last post by:
Hi, I'm a beginner is using C# and .net. I have big legacy files that stores various values (ints, bytes, strings) and want to read them into a C# programme so that I can store them in a...
2
by: joakim.hove | last post by:
Hello, I am having great problems writing norwegian characters æøå to file from a python application. My (simplified) scenario is as follows: 1. I have a web form where the user can enter his...
0
by: nmsreddi | last post by:
Hi friends I am working on serialport in c# ,i am using C#2005 i have successfully done the serial communication with GSM modem and able to send and receive data , the main problem ,the serial...
6
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me....
4
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. ...
9
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.