Solved

VB functions in delphi

Posted on 2006-11-06
6
284 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
ID: 17881067
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
ID: 17881146
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
ID: 17881246
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17881255
probably need to double up the '

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

Expert Comment

by:mikelittlewood
ID: 17881279
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
ID: 17881280
Thanks for your help
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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