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
1 4155
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. - Option Explicit
-
DefLng A-Z
-
Private Sub Form_Click()
-
Dim s As String
-
Dim TempNum As String, Char As String * 1
-
Dim I As Long, T As Long, T2 As Single
-
-
's = vbCrLf & "999,1.52,32.85,5.91,15.81,1.39,26.17,15.75,12.3"
-
s = "<cr><lf>999,1.52,32.85,5.91,15.81,1.39,26.17,15.75,12.3"
-
For I = 1 To Len(s)
-
Char = Mid$(s, I, 1)
-
T = T + Asc(Char)
-
Debug.Print Asc(Char), T
-
Next
-
Debug.Print "Method 1: "; T
-
-
For I = 1 To Len(s)
-
Char = Mid$(s, I, 1)
-
Select Case Char
-
Case "0" To "9", "."
-
TempNum = TempNum & Char
-
Case Else
-
T2 = T2 + Val(TempNum)
-
Debug.Print TempNum, T2
-
TempNum = ""
-
End Select
-
Next
-
T2 = T2 + Val(TempNum)
-
Debug.Print "Method 2: "; T2
-
End Sub
Here's what it displayed... - 49 2864
-
50 2914
-
46 2960
-
51 3011
-
Method 1: 3011
-
-
-
-
-
-
-
-
-
999 999
-
1.52 1000.52
-
32.85 1033.37
-
5.91 1039.28
-
15.81 1055.09
-
1.39 1056.48
-
26.17 1082.65
-
15.75 1098.4
-
Method 2: 1110.7
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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....
|
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.
...
|
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....
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
| |