Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete part of string

Status
Not open for further replies.

RandyMcI

Technical User
Jul 7, 2001
5
CA
I have a text field that was populated by the "& concatenation", of a couple of other fields.

Now I want to be able delete a part of the text field.

With a command button I can selete the text that I want delete but I cannot find the operator necessary to the task.

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click


strPhrase = fldPhrase
Text.Value = Text.Value - ("" "" & strPhrase)

Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox err.Description
Resume Exit_Command16_Click
End Sub

Where (" " & strPhrase) is what I want to remove.

Thanks

Randy
 
Hi,

you need to use the Mid$ function to extract the parts that you want to keep. Thus:

strText = Mid$ (strText, 1, 4) & Mid$ (strText, 6)

This copies the first 4 characters of strtext and appends everything from character 6 onwards.

John
 
You could try
Code:
Dim x As Integer

x = InStr(txtOriginal, txtRemove)
If x > 0 Then
   txtOriginal = Left(txtOriginal, x - 1) & Mid(txtOriginal, x + Len(txtRemove))
End If

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Or there's the other way:

Text.Value=replace(Text.Value,"" "" & strPhrase,"")

replaces all the instances of "" "" & strPhrase in Text.Value with ""

If you're using A97 then you need to get the code from
hth

Ben


----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top