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!!!!

one more question, is replace function case sensitive?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.