BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delphi ObjectOriented Noobie Question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Josh
Guest





PostPosted: Wed Aug 23, 2006 1:22 am    Post subject: Delphi ObjectOriented Noobie Question Reply with quote



Hey All!

I've been using delphi now a little over a year, and want to start
expanding my knowledge by using objects.

I have OO experience using Java and C++ so OO design isn't completely
foreign to me.

My Question. I have created a simple object that is going to be an
Accounting Journal entry.

I have a setInvoiceNumber that accepts a string variable. (To set the
private fInvoiceNumber variable)

How would I check that the string was in the proper data format?
AlphaNumeric "Space" Numeric

Example B 11111

Cheers!

Josh
Back to top
Iman L Crawford
Guest





PostPosted: Wed Aug 23, 2006 1:28 am    Post subject: Re: Delphi ObjectOriented Noobie Question Reply with quote



Josh <josh (AT) nospam (DOT) org> wrote in news:44eb6776$1 (AT) newsgroups (DOT) borland.com:
Quote:
How would I check that the string was in the proper data format?
AlphaNumeric "Space" Numeric

I would download a regexp library.


--
Iman
Back to top
Leonardo M. Ramé
Guest





PostPosted: Tue Aug 29, 2006 11:46 pm    Post subject: Re: Delphi ObjectOriented Noobie Question Reply with quote



Iman L Crawford <ilcrawford.at.hotmail.dot.com> wrote:
Quote:
Josh <josh (AT) nospam (DOT) org> wrote in news:44eb6776$1 (AT) newsgroups (DOT) borland.com:
How would I check that the string was in the proper data format?
AlphaNumeric "Space" Numeric

I would download a regexp library.


--
Iman


If you don't want to use regular expressions you can use a block of code like this:


var
lStr: string;
lAlpha: string;
lNumeric: string;
lInteger: Integer;
begin
(* To find the first (alphanumeric) part of the string *)
lStr := 'ABCD 1234';
if(pos(' ', lStr) > 0) then
begin
lAlpha := copy(lStr,0, Pos(' ', lStr) - 1);
lNumeric := copy(lStr,Pos(' ', lStr) + 1, length(lStr) - length(lAlpha) - 1);
(* Then you can check if lNumeric is an integer *)
if TryStrToInt(lNumeric, lInteger) then
lInteger := StrToInt(lNumeric);
end
else
Showmessage('Not the type of string i need');
end;

----------------
Leonardo M. Ramé
http://leonardorame.blogspot.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.