Re: String manipulation



"Nicholas Graham" <nsgraham@xxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:Pine.LNX.4.44.0504132237250.11173-100000@xxxxxxxxxxxxxxxxxxxxxxxxxx
|
| I'm writing a program that requires some string manipulations. Let's say
| I have a string
|
| s='x'
|
| Now, the ascii code for 'x' is 0x78. I want to be able to perform
| operations on this number, and print the character corresponding to the
| results of the operation. For example, the pseudo-code looks like:
|
| -read in string s from external file (for simplicity, we'll keep s='x')
|
| -determine the code for s (should be 0x78 or 120 in base 10), store it in
| variable c
|
| -add a literal to c (let's say c=c+1)
|
| -find out which character corresponds to the new code c=0x79
|
| -store the character in a new string s2
|
| At the end of this, I want s2='y'
|
| Any suggestions?

Take a look at the built-in functions ord() and chr() -- Chapter 2.1 of the
manual.

>> s = 'x'
>> c = ord(s)
>> c
120
>> c+=1
>> s2 = chr(c)
>> s2
'y'

--

Vincent Wehren

|
| NG
|


.



Relevant Pages

  • Need help to remove tbas, carriage retrun, and other!!!
    ... ASCII code of the character ... that I link to) to specify the string that you want to ... optionally the ascii chr number of the delimiter ... 'At the start point of the string (1 character after the ...
    (microsoft.public.access.queries)
  • RE: Advanced Filter/Sort for Mixed Number and Letter Variables
    ... you run a query using ASCyou will get the ASCII code number for each, ... you can change the string of numerals into an actual value ... "Michael Conroy" wrote: ... numbers and letters were seperated at one time, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Character representation
    ... >> Also is there any character to ASCII code and ASCII code to character ... we use vbKeyTab for Tab and vbCrLf for line feed in VB) ... > However, you'll probably want them as string (and for vbCrLf, it would ...
    (microsoft.public.dotnet.languages.csharp)
  • End of String Character?
    ... string using some extended ASCII characters (ASCII code> 128) ... I am wondering if there is a reserved character in VB that signifies ... the end of a string of characters. ... Is my encryption algorithm possible generating a reserved character ...
    (microsoft.public.scripting.vbscript)
  • Re: Problem with string.indexofany
    ... > I have string where i have to find every character with ASCII code between 0 ... If replying to the group, please do not mail me too ...
    (microsoft.public.dotnet.languages.csharp)