|
-
Nov 3rd, 2002, 05:30 PM
#1
Thread Starter
Frenzied Member
Replacing a Certain Character (resolved)
Hello. I want to replace a very specific character with another
character, going by the number. This meaning, i want to replace
characters by which character they are.
Lets take the string "abcdefghijklmnopqrstuvwxyz". I want to be
able to take, say the fifth character in it ("e") and replace it with
some other character (lets say "c"), how could i accomplish this?
Last edited by macai; Nov 4th, 2002 at 06:27 AM.
Luke
-
Nov 3rd, 2002, 05:32 PM
#2
Hyperactive Member
VB Code:
sNewString = Replace("abcdefghijklmnopqrstuvwxyz","e","c")
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
-
Nov 3rd, 2002, 05:33 PM
#3
Thread Starter
Frenzied Member
THat will replace every single copy of "e" with "c". I want that
SPECIFIC copy of "e" to be replace with "c". Get where im at?
-
Nov 3rd, 2002, 05:39 PM
#4
Frenzied Member
Use the Mid and InStr functions.
-
Nov 3rd, 2002, 05:55 PM
#5
Thread Starter
Frenzied Member
VB Code:
Public Function RpChr(Expression As String, ChrNm As Long, ChrRp As String)
RpChr = Left(Expression, ChrNm - 1) & Replace(Expression, Mid$(Expression, ChrNm, 1), ChrRp, ChrNm, 1)
End Function
RpChr Function
Parameters
Expression
A string containing the data which will be replaced.
ChrNm
The character number that will be replaced.
ChrRp
The character which ChrNm will be replaced with.
Example
VB Code:
x = RpChr("abcdefghijklmnopqrstuvwxyz", 5, "c")
This will return "abcdcfghijklnmopqrstuvwxyz".
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
|