P
Paul
Hi,
I am trying to check a string to see if it's first 3 characters are numeric
and if they are, to replace those 3 characters with something else.
I've tried this but nothing happens...
newname = Replace(newname, VB.Left(newname, 3) = "101-", "101. ")
The method I've been using up to now is very drawn out and too long and I
need a more efficient way of doing it.
This is what I've beeni using...
If VB.Left(newname, 3) = "01-" Or VB.Left(newname, 3) = "02-" _
Or VB.Left(newname, 3) = "03-" Or VB.Left(newname, 3) = "04-" _
Or VB.Left(newname, 3) = "05-" Or VB.Left(newname, 3) = "06-" _
Or VB.Left(newname, 3) = "07-" Or VB.Left(newname, 3) = "08-" _
Or VB.Left(newname, 3) = "09-" Or VB.Left(newname, 3) = "10-" Then
newname = Replace(newname, "01-", "01. ")
newname = Replace(newname, "02-", "02. ")
newname = Replace(newname, "03-", "03. ")
newname = Replace(newname, "04-", "04. ")
newname = Replace(newname, "05-", "05. ")
newname = Replace(newname, "06-", "06. ")
newname = Replace(newname, "07-", "07. ")
newname = Replace(newname, "08-", "08. ")
newname = Replace(newname, "09-", "09. ")
newname = Replace(newname, "10-", "10. ")
End If
Any ideas?
Cheers,
Paul
I am trying to check a string to see if it's first 3 characters are numeric
and if they are, to replace those 3 characters with something else.
I've tried this but nothing happens...
newname = Replace(newname, VB.Left(newname, 3) = "101-", "101. ")
The method I've been using up to now is very drawn out and too long and I
need a more efficient way of doing it.
This is what I've beeni using...
If VB.Left(newname, 3) = "01-" Or VB.Left(newname, 3) = "02-" _
Or VB.Left(newname, 3) = "03-" Or VB.Left(newname, 3) = "04-" _
Or VB.Left(newname, 3) = "05-" Or VB.Left(newname, 3) = "06-" _
Or VB.Left(newname, 3) = "07-" Or VB.Left(newname, 3) = "08-" _
Or VB.Left(newname, 3) = "09-" Or VB.Left(newname, 3) = "10-" Then
newname = Replace(newname, "01-", "01. ")
newname = Replace(newname, "02-", "02. ")
newname = Replace(newname, "03-", "03. ")
newname = Replace(newname, "04-", "04. ")
newname = Replace(newname, "05-", "05. ")
newname = Replace(newname, "06-", "06. ")
newname = Replace(newname, "07-", "07. ")
newname = Replace(newname, "08-", "08. ")
newname = Replace(newname, "09-", "09. ")
newname = Replace(newname, "10-", "10. ")
End If
Any ideas?
Cheers,
Paul