char to ascii

convert char array to ascii array

Page 1 of 1

3 Replies - 8069 Views - Last Post: 05 December 2009 - 06:53 PM Rate Topic: -----

#1 taufik.eliners  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-December 09

char to ascii

Posted 05 December 2009 - 05:38 PM

everyone could you help me to convert char to ascii in array form?.
asci[a]
but a is char array.
i need a syntax for it.
please email me in [removed]

thank.
:D

Admin Note: Please keep all the communication on the forums.

This post has been edited by Core: 06 December 2009 - 03:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: char to ascii

#2 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: char to ascii

Posted 05 December 2009 - 05:43 PM

Try something like this - the following will convert the char array into an integer array representing the ascii values:

 Dim charArray As Char() = {"a", "b", "c", "d"} 'a char array
		Dim integerArray(charArray.Length) As Integer 'an integer array with the same capacity of the char array

		For meh As Integer = 0 To charArray.Length - 1 'a for loop counting to the end of the char array
			integerArray(meh) = Asc(charArray(meh)) 'populates a slot of the int array with the ascii value of the same index in the char array
		Next


This post has been edited by LeisureProgrammer: 05 December 2009 - 05:55 PM

Was This Post Helpful? 1
  • +
  • -

#3 taufik.eliners  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-December 09

Re: char to ascii

Posted 05 December 2009 - 05:54 PM

View PostLeisureProgrammer, on 5 Dec, 2009 - 04:43 PM, said:

i will try it.
thank you very much.

Was This Post Helpful? 0
  • +
  • -

#4 crepitus  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 84
  • View blog
  • Posts: 383
  • Joined: 08-September 09

Re: char to ascii

Posted 05 December 2009 - 06:53 PM

Or a function that does it using Linq....

Private Function CharsToAscii(ByVal chars As IEnumerable(Of Char)) As Integer()
   Return (From c In chars Select Asc(c)).ToArray
End Function

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1