954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Replace Function, Please Help!!!!!

I am trying to replace a string with another string in a string, but it is just not happeneing and is driving me crazy :@ and I am really confused :confused:
Here is the snippet :

Dim strHex2 As String
strHex2 = strHex.Text
Dim Mystring2 As String
Dim GG As Integer

GG = FreeFile()
Open ("d:\ImageHex.dat") For Binary As GG

'For a string, do this:
Mystring2 = Space(LOF(GG))
Get GG, , Mystring2
txthex.Text = Mystring2


Close GG


Dim strRTF As String

Dim strIMHex As String


strRTF = rtfTxt.Text


Dim Mystring3 As String
Dim strHex3 As String




Mystring3 = Replace(Mystring2, Chr(32), "")

strHex3 = Replace(strHex2, Chr(32), "")

Dim strResult As String


strResult = Replace(strRTF, Mystring3, strHex3)


so, strResult is the same as strRTF with no changes, and i dont know why?
Please HELP!!!!

ChroNoS
Light Poster
30 posts since Aug 2008
Reputation Points: 13
Solved Threads: 0
 

one more question, is replace function case sensitive?

ChroNoS
Light Poster
30 posts since Aug 2008
Reputation Points: 13
Solved Threads: 0
 
one more question, is replace function case sensitive?


By default, yes. Unless you have

Option Compare Text

Here's an example

Dim str As String
str = "ABC"
str = Replace(str, "b", "x", , , vbBinaryCompare)


results "ABC" and vbBinaryCompare is the default compare method in VB6

str = Replace(str, "b", "x", , , vbTextCompare)

results "AxC".

If you put a breakpoint in the line

strResult = Replace(strRTF, Mystring3, strHex3)

what would strRTF, Mystring3 and strHex3 contain?

Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You