display the total of all the ASCII values(integer values) of each lett

display the total of all the ASCII values(integer values) of each lett

Page 1 of 1

1 Replies - 11479 Views - Last Post: 27 May 2008 - 08:57 AM Rate Topic: -----

#1 kele  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-May 08

display the total of all the ASCII values(integer values) of each lett

Post icon  Posted 27 May 2008 - 08:34 AM

Dim sTotal1 As String
		Dim sTotal2 As String
		Dim Prompt As String = "Enter Value"
		Dim lTextLength As Long
		Dim sChar As String
		Dim bASCII As Byte
		Dim x As Long

		sTotal1 = "The quick red fox jumped over the lazy brown dog"
		lTextLength = Len(sTotal1) 'Gets # of chars in sTotal1
		lTextLength = InputBox(Prompt, "display total of ASCII values")
		For x = 1 To lTextLength 'Loop through string one char at a time
			sChar = Mid$(sTotal1, x, 1) 'Gets the x'th charcter in sTotal1
			bASCII = Asc(sChar)	  'Gets ASCII value of character
			MsgBox("The ASCII value of '" & sChar & "' is " & bASCII) 'Display results
		Next x

	End Sub


Write a program that will display the total of all the ASCII values(integer values) of each letter in a string (not including spaces). For your reference the ASCII value of 'A' is 65. You must use a loop in the calculation and you must use a VB procedure within VB.NET to return the ASCII code for an individual letter.

The program should produce two totals, the first using the following sentence as a fixed string:-

"The quick red fox jumped over the lazy brown dog"

The total should then be displayed.

Then, using an empty string of 80 characters maximum length, input any sentence using both alphanumeric and numeric characters.

For example:

"Snow white and the 7 dwarves waited for Prince Charming:- he was late!"

The program should then calculate and display the total in a similar way as for the first example.


HOW DO I REMOVE THE SPACES
HOW DO I DISPLAY THE TOTAL

Is This A Good Question/Topic? 0
  • +

Replies To: display the total of all the ASCII values(integer values) of each lett

#2 djkitt  Icon User is offline

  • D.I.C Head

Reputation: 29
  • View blog
  • Posts: 189
  • Joined: 22-May 08

Re: display the total of all the ASCII values(integer values) of each lett

Posted 27 May 2008 - 08:57 AM

View Postkele, on 27 May, 2008 - 10:34 AM, said:

HOW DO I REMOVE THE SPACES

The ASCII value for a space is 32. You could test for this value and not include it in your totals.


View Postkele, on 27 May, 2008 - 10:34 AM, said:

HOW DO I DISPLAY THE TOTAL


You can display the total using MsgBox just like you do to display the 'results'.

(On an aside, I do not see the purpose behind the InputBox. You should probably just whack that line of code.)

Hope that helped.

This post has been edited by djkitt: 27 May 2008 - 08:59 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1