New topic: 

Inserting text characters into a string

<http://forums.realsoftware.com/viewtopic.php?t=28138>

  Page 1 of 1
 [ 3 posts ]  Previous topic | Next topic AuthorMessageBoboo Post subject: 
Inserting text characters into a stringPosted: Tue May 19, 2009 10:59 pm 
Joined: Wed Dec 14, 2005 3:52 pm
Posts: 42 Back in my VB days I was able to use Mid to insert characters into a 
string, as in:

dim a as string
a = "....."
mid(a,2,2) = "XX"

and get ".XX.."

Can I do the same thing in RB? I have searched through the language reference 
and can't find anything like this.
--Bob
Top  timhare Post subject: Re: Inserting text characters into a stringPosted: 
Tue May 19, 2009 11:15 pm 
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 5374
Location: Portland, OR USA Strings in RB are immutable. You cannot change the 
middle of the string via Mid, etc. You CAN put the string into a MemoryBlock, 
change the contents, and pull a new string out of it.
Code:dim s as string = "...."
dim mb as memoryblock = s
mb.StringValue(1,2)= "XX"
s= mb.StringValue(0,4)
// s is now .XX.


Tim
Top  Bessie Post subject: Re: Inserting text characters into a stringPosted: 
Wed May 20, 2009 1:05 am 
Joined: Tue Mar 17, 2009 8:53 am
Posts: 585 Boboo wrote:dim a as string
a = "....."
mid(a,2,2) = "XX"
You just doCode:a = a.left(2) + "XX" + a.mid(4)
_________________
No thanks, I don't want to buy any plugins.
Top  Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 
months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1
 [ 3 posts ] 

-- 
Over 900 classes with 18000 functions in one REALbasic plug-in. 
The Monkeybread Software Realbasic Plugin v8.1. 

&lt;http://www.monkeybreadsoftware.de/realbasic/plugins.shtml&gt;

[email protected]

Reply via email to