VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
String Manupilation Posted by DWDuck on 31 Mar 2011 at 6:41 AM
Good day reader

I want to know how to do a couple of things with strings for instance

turn 123456 into 654321

then I also want to change the asci value of a character.

Here follows the code that I thought would fdo both of the above, could you correct me?

First query

Dim Str1 as Strings = "123456"
Dim Str2() as char = str1.tochararray
Dim st3() as char
Dim I as integer
dim J as integer
dim K as integer

J = len(str1)
for i = 1 to len(str1)
K = J+1-I
str3(i) = Str2(K)
next i

Str1 = Str3

this should turn str1 into "654321"

Second query

Dim Str1 as String = "ABC"
Dim Str2() as char = str1.tochararray
Dim Str3() as Char
Dim I integer
Dim J integer = 20
DIm Ch as char


For I = 1 to len(str1)
ch = chr(asc(Str2(i)+10)
Str3(i) = ch
next i

Str1 = Str3

This should turn str1 into "KLM"

Can someone tell me where I went wrong (I come from a Delphi background, the direct translated code for delphi would have worked but for some reason it doesn't work in VB)



Darkwing Duck aka DWduck signing off :)
Thread Tree
DWDuck String Manupilation on 31 Mar 2011 at 6:41 AM
DaiMitnick Re: String Manupilation on 5 Apr 2011 at 2:45 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.