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.
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.
1: Do you mean Left$ Mid$ and Right$ ?
2: What's "Pos" for ?
maybe I could write some functions that do the same.
bryan
2: What's "Pos" for ?
maybe I could write some functions that do the same.
bryan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.co unt);
¤¤¤¤¤¤¤ InThe ¤¤¤¤¤¤¤
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.co
¤¤¤¤¤¤¤ InThe ¤¤¤¤¤¤¤
And to locate text in a string:
function LocateText(TotalText,TextT oFind: 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
function LocateText(TotalText,TextT
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
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
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
ASKER
bryan7,
That would be cool, whats your email address?
dokken
That would be cool, whats your email address?
dokken
AerithFantasy@earthling.ne t
AERISFANTASY@EARTHLING.NET
send a checking email.
bryan =)
AERISFANTASY@EARTHLING.NET
send a checking email.
bryan =)
sorry, I mean,
AERITHFANTASY@EARTHLING.NE T
bryan
AERITHFANTASY@EARTHLING.NE
bryan
You can either write some by yourself or lookup on the internet.