Link to home
Start Free TrialLog in
Avatar of dokken
dokken

asked on

New to Delphi, need some help...

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.
Avatar of dwwang
dwwang

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.
1: Do you mean Left$ Mid$ and Right$ ?
2: What's "Pos" for ?

maybe I could write some functions that do the same.

bryan
ASKER CERTIFIED SOLUTION
Avatar of bryan7
bryan7
Flag of Japan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 ¤¤¤¤¤¤¤
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


Avatar of dokken

ASKER

Thanks for the help, you guys answered my questions perfectly!
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
Avatar of dokken

ASKER

bryan7,

That would be cool, whats your email address?

dokken
AerithFantasy@earthling.net

AERISFANTASY@EARTHLING.NET

send a checking email.

bryan =)

sorry,  I mean,

AERITHFANTASY@EARTHLING.NET

bryan