[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB functions in delphi

Posted on 2006-11-06
6
Medium Priority
?
289 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 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