Solved

VB functions in delphi

Posted on 2006-11-06
6
282 Views
Last Modified: 2010-04-05
Hi EE

I was wondering if there was a left, mid, right and split functions in delphi? Also I want to remove/replace any ' characters in a string is this possible?

Thanks in advance

Paul
0
Comment
Question by:Paulstott
  • 2
  • 2
  • 2
6 Comments
 
LVL 21

Expert Comment

by:ziolko
Comment Utility
You can use Copy() to get left, right and mid characters and StringReplace() to replace and Delete() to remove.

ziolko.
0
 
LVL 1

Author Comment

by:Paulstott
Comment Utility
Hi Ziolko,

Thanks for your answer

Would you use the pos function with the copy()? Do you have any example of this?

With string replace I have tried:

StringReplace(aString, ' ' ', ' ', [rfReplaceAll, rfIgnoreCase]); and get an error message, how can I get rid of ' (apostrophe).

Is there a split function or a way to get round this?
0
 
LVL 21

Accepted Solution

by:
ziolko earned 250 total points
Comment Utility
1. use: StringReplace(aString, '''', '', [rfReplaceAll, rfIgnoreCase]);
(You have to double each: >>'<< within string)

2. yup You can use Pos() with Copy()
var s: string;
     hello, world: string;
     delim: Integer;

s := 'Helo Wrold';
delim := Pos(' ', s);
hello := Copy(s, 1, delim - 1);
world := Copy(s, delim + 1, MaxInt);

ziolko.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 15

Expert Comment

by:mikelittlewood
Comment Utility
probably need to double up the '

StringReplace(aString, ' '' ', ' ', [rfReplaceAll, rfIgnoreCase]);
0
 
LVL 15

Expert Comment

by:mikelittlewood
Comment Utility
Here is another split string function I have been using.
Passes back the first string up to the delimiter while also trimming the original string.

function SplitStr(Var AString : String; ADelim : String) : String;
var APos : Integer;
begin
  Result := '';
  APos := Pos(ADelim,AString);
  if APos > 0 then
  begin
    Result := Copy(AString,1,APos-1);
    AString := copy(Astring,APos+length(Adelim),MaxLongInt);
  end
  else
  begin
    Result := AString;
    AString := '';
  end;
end;
0
 
LVL 1

Author Comment

by:Paulstott
Comment Utility
Thanks for your help
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now