Discussion:
Replace function in VB6 - not working?
(too old to reply)
Acie
2004-02-12 21:31:06 UTC
Permalink
I just tried using the Replace function for the first time, and it is not working for me
Any ideas/thoughts??? -Do I have to include some external reference for it to work??

The following subroutine creates the following

Compile Error

Wrong number of arguments or invalid property assignment

Private Sub Command2_Click(
Dim str1 As Strin
Dim str2 As Strin
Dim str3 As Strin
Dim str4 As Strin

str1 = "This is a new brave world full of strangers with weird BRAVE habits
str2 = "brave
str3 = "weak
str4 = replace(str1, str2, str3
End Su
Jim Edgar
2004-02-12 21:45:59 UTC
Permalink
Post by Acie
I just tried using the Replace function for the first time, and it is not working for
me.
Post by Acie
Any ideas/thoughts??? -Do I have to include some external reference for it to work???
Wrong number of arguments or invalid property assignment.
Private Sub Command2_Click()
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
str1 = "This is a new brave world full of strangers with weird BRAVE habits"
str2 = "brave"
str3 = "weak"
str4 = replace(str1, str2, str3)
End Sub
Your code, cut and pasted into my project, works just fine for me. Try the following:

str4 = VBA.Replace(str1, str2, str3)

If it works then open the references dialog and make sure that there is a check
next to: Visual Basic for Applications.

BTW - you are using VB6, not VB.Net aren't you?

HTH,

Jim Edgar
Acie
2004-02-13 13:36:07 UTC
Permalink
Edgar - It worked !!!

Yeah, I'm using VB 6.0.

----- Jim Edgar wrote: -----
Post by Acie
I just tried using the Replace function for the first time, and it is not working for
me.
Post by Acie
Any ideas/thoughts??? -Do I have to include some external reference for it to work???
Post by Acie
Wrong number of arguments or invalid property assignment.
Private Sub Command2_Click()
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
Post by Acie
str1 = "This is a new brave world full of strangers with weird BRAVE habits"
str2 = "brave"
str3 = "weak"
str4 = replace(str1, str2, str3)
End Sub
Your code, cut and pasted into my project, works just fine for me. Try the following:

str4 = VBA.Replace(str1, str2, str3)

If it works then open the references dialog and make sure that there is a check
next to: Visual Basic for Applications.

BTW - you are using VB6, not VB.Net aren't you?

HTH,

Jim Edgar

Loading...