|
-
Feb 28th, 2005, 12:22 AM
#1
Thread Starter
New Member
string manipulation
i have a general question about string manipulation:
let's say for example that i have an input box. in this input box a user can type in any random string of characters (e.g. ALWOGHKEIRT). How would I code a button so that each time it is clicked a space is inserted between "W"'s and "O"'s for example? so, "ALWOGHKEIRT" becomes
"ALW OGHKEIRT" (or "DPLIJWOLMNSGWOP" becomes "DPLIJW OLMNSGW OP" or any other random string)
thanks
-
Feb 28th, 2005, 03:13 AM
#2
Re: string manipulation
 Originally Posted by superTA
i have a general question about string manipulation:
let's say for example that i have an input box. in this input box a user can type in any random string of characters (e.g. ALWOGHKEIRT). How would I code a button so that each time it is clicked a space is inserted between "W"'s and "O"'s for example? so, "ALWOGHKEIRT" becomes
"ALW OGHKEIRT" (or "DPLIJWOLMNSGWOP" becomes "DPLIJW OLMNSGW OP" or any other random string)
thanks
Dim a As String = "DPLIJWOLMNSGWOP"
a = a.Replace("WO", "W O")
rate my post
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 28th, 2005, 03:35 AM
#3
Thread Starter
New Member
Re: string manipulation
mr. polite
thanks for the response. only thing: i need that concept to work for any string that the user types into the input box.
so, for any string typed into the input box would i write:
Dim a As String = inputbox.text
a = a.Replace("WO", "W O")
or something like
Dim errString As String = InputBox.Text
Dim correctString As String = errString.Replace("WO", "W O").
as i can tell, your method applies specifically, to the "DPLIJWOLMNSGWOP" in my example. but, it should apply for any string typed into the input box
your input is appreciated
-
Feb 28th, 2005, 11:25 AM
#4
Re: string manipulation
Either of your two examples would work, but the second one will require a different variable, which is slightly less efficient than the first example.
Personlaly, I prefer to define the variable:
Dim str as string
Then assign to it:
str=InputBox.text
But that is just my preference. I feel it is more readable, but it should make no difference in performance.
My usual boring signature: Nothing
 
-
Feb 28th, 2005, 04:35 PM
#5
Re: string manipulation
doesnt matter how you do it. It just depends to your preferences as shaggy hiker said. If you dont need the original inputted string then you dont really need a separate variable for that. You can keep it as short as this:
Dim strInput As String = InputBox.Text.Replace("WO", "W O")
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|