Jump to content

Replace Function

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
barnigan

barnigan

    Newbie

  • Members
  • PipPip
  • 11 posts
when i run Replace(SerStr,RepStr,RepTo) it gives an error

"Cannot use parentheses when calling a Sub"

here's the code:
elseif InStr(SerStr, Ser)<>0 Then
if mid(SerStr,instr(SerStr,Ser)+len(Ser)+1,1) = 0 and Err <> 0 Then
countErr = CountErr+1
RepStr = mid(SerStr,instr(1,SerStr,Ser,1),len(Ser)+2)
RepTo = Ser & "-" & Err

Replace(SerStr,RepStr,RepTo)
end if

SerStr - contains a string serial numbers and if it has an error (ex. 123455-0)
RepStr - pulls the string i want to replace out of SerStr
RepTo - the new string I want to add

Does anyone know why this would happen

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
Try
Replace SerStr,RepStr,RepTo
instead of
Replace(SerStr,RepStr,RepTo)
.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
barnigan

barnigan

    Newbie

  • Members
  • PipPip
  • 11 posts
well, that got rid of the error but now the replace function isn't doing anything

#4
barnigan

barnigan

    Newbie

  • Members
  • PipPip
  • 11 posts
Found a way around it by making my own replace

SplF = mid(SerStr,1,InStr(SerStr,RepStr)-1)
SplS = RepTo & mid(SerStr,(len(SplF)+1)+len(RepStr))
SerStr = SplF + SplS

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts

WingedPanther said:

Try
Replace SerStr,RepStr,RepTo
instead of
Replace(SerStr,RepStr,RepTo)
.
Please use CODE tags! Geez..
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums