Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with incrementing strings
Message
From
27/02/2005 16:49:35
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00991021
Message ID:
00991041
Views:
19
Gerard,

I think if you throw one more thing into the mix, you'd get it to work. String has a .ToCharArray() method. Once you get your string into a char array, I think you'll have an easier time incrementing it.

~~Bonnie



>Hi.
>I am trying to increment a string and am having problems, mostly to do
> with the synstax of Int and Char functions.
>
>I have a sring with two letters in it e.g. 'CF'
>I want to 'Increment' the string by 1
>e.g. Old string New string
> CF CG
> CZ DA etc
>
>IN VFP I would do the following:
>
>IF SUBSTR(MyString,2,1) = "Z"
> MyString = CHR(ASC(SUBSTR(MyString,1,1)) + 1) + "A"
>ELSE
> MyString = SUBSTR(MyString,1,1) + CHR(ASC(SUBSTR(MyString,2,1)) + 1)
>ENDIF
>
>Any ideas on how to do this in .Net
>(I've use a combinarion of Int and Char and Substr but am getting syntax errors)
>
>regards,
>
>Gerard
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform