?
Solved

VB functions in delphi

Posted on 2006-11-06
6
Medium Priority
?
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

743 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