 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Josh Guest
|
Posted: Wed Aug 23, 2006 1:22 am Post subject: Delphi ObjectOriented Noobie Question |
|
|
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
|
Posted: Wed Aug 23, 2006 1:28 am Post subject: Re: Delphi ObjectOriented Noobie Question |
|
|
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
|
Posted: Tue Aug 29, 2006 11:46 pm Post subject: Re: Delphi ObjectOriented Noobie Question |
|
|
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 |
|
 |
|
|
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
|
|