Solved

New to Delphi, need some help...

Posted on 1998-10-25
10
140 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 161
oracle global variables 4 76
Drag & Drop... Data from one grid to another 2 41
Twebbrowser in Fire monkey android scrolling to bottom 1 44
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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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