|
-
Nov 23rd, 2003, 06:50 PM
#1
Thread Starter
Member
Replace Function Question
I am trying to replace nothing with something. Here is an example:
VB Code:
Dim Test as String
Test = ""
Test = Replace(Test, "", "-", 1)
If I then message Test, it still comes back with nothing. Anyone have any ideas?
-
Nov 23rd, 2003, 07:00 PM
#2
PowerPoster
?? Just think about that for a minute...please....
You want to replace every occurance of "" with something (lets say "A" for our purpose).
Look at this string, and tell me where "" happens:
"Hello"
Well, it happens before H, so lets add our character there.
"AHello"
Now, after A, there is another ""
"AAHello"
Oh, look at that, another one:
"AAAHello"
It is a neverending loop.
Now if you are wanting to take a empty string, and put a character, just do this:
If Test = "" then
Test = "-"
End If
-
Nov 23rd, 2003, 08:48 PM
#3
Lively Member
he was giving an example to replace the occurance, not the actual code. well hellswrath is right, "" is everywhere. but the loop is not everlasting. after "" there can't be another "" because the length of "" won't fit in the string.
DannyJoumaa
Advanced VB6 Programmer
Intermediate-Advanced VB .NET Programmer
Intermediate C# Programmer
Intermediate Win32 Developer
Beginner Mac OS X Developer
Contact: [email protected]
Favorite Sayings:
"Every time you open your mouth, you prove your an idiot."
"God is a programmer. Satan is a bug. Life is debugging."
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
|