Solved

New to Delphi, need some help...

Posted on 1998-10-25
10
137 Views
Last Modified: 2010-08-05
Hi, I'm a VB programmer that is switching to Delphi and theres a few things I need some help with.  

1. In VB I used to use Left,Mid, & Right.  I couldn't find anything like that in Delphi... maybe I missed it, I don't know.  Is there anything like that in Delphi?

2. I used to use instr in VB to locate text in a string, it worked great because I could tell it where to start.  The closest thing I found in Delphi is the Pos... is there anything in Delphi thats like instr?

ohh yeah, and one last question... using a listbox how can I get the total items in it?

Thanks for the help.
0
Comment
Question by:dokken
10 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1344262
I would like to say Delphi is a "REAL" low level programming language so there are not somany build-in functions as VB has.

You can either write some by yourself or lookup on the internet.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344263
1: Do you mean Left$ Mid$ and Right$ ?
2: What's "Pos" for ?

maybe I could write some functions that do the same.

bryan
0
 
LVL 3

Accepted Solution

by:
bryan7 earned 60 total points
ID: 1344264
try this:

function Mid(Finalstring,Initialstring: string; InitialPos,NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= InitialPos to (InitialPos + NumberOfCharacters -1 ) do
      FinalString:= FinalString + Initialstring[a];
end;

function Left(Finalstring,Initialstring: string; NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= 1 to NumberOfCharacters do
      FinalString:= FinalString + Initialstring[a];
end;

function Right(Finalstring,Initialstring: string; NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= Length(InitialString) downto (Length(InitialString) - NumberOfCharacters +1) do
      FinalString:= FinalString + Initialstring[a];
end;

bryan
           
0
 
LVL 17

Expert Comment

by:inthe
ID: 1344265
Hello Dokken

pos returns the index value of the first character in a specified substring that occurs in a givin string.  

and  for the listbox items it's :
edit1.text:= inttostr(listbox1.items.count);

¤¤¤¤¤¤¤ InThe ¤¤¤¤¤¤¤
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344266
And to locate text in a string:

function LocateText(TotalText,TextToFind: string, PosFrom,PosFound: Integer): Integer;
Var a,b: Integer;
      c: string;
begin
c:= '';
For  a:=  PosFrom to length(TotalText) do
    begin
          c:='';
          for b:= a to (a+length(TextToFind)-1) do
               c:= c+TotalText[b];
          if c= TextToFind then
                begin
                       PosFound:= a;
                       Exit;
                end;
    end;
PosFound:= 0;
end;

If it returns 0, then the text wasn't found.
I've not tested it with Delphi, but it should work, as Delphi is somehow like Pascal.

I'll test it later and fix any bugs if there are..

bryan


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dokken
ID: 1344267
Thanks for the help, you guys answered my questions perfectly!
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344268
hey dokken,

Soon I'll start with VB5, then we could exchange some knowledges about
 Delphi - VB5, what do you think ?

Give me your email, if you want so.

bryan
0
 

Author Comment

by:dokken
ID: 1344269
bryan7,

That would be cool, whats your email address?

dokken
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344270
AerithFantasy@earthling.net

AERISFANTASY@EARTHLING.NET

send a checking email.

bryan =)

0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344271
sorry,  I mean,

AERITHFANTASY@EARTHLING.NET

bryan

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 79
How to use Hashing sha1 in Delphi 2010 4 204
Printing problem 2 81
QRReport  TQrmemo vertical stretching 1 42
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

18 Experts available now in Live!

Get 1:1 Help Now