Cara Mengkonversi Angka Romawi Ke Angka Arab

Sistem penomoran yang sering dipakai adalah sistem penomoran angka arab. Angka arab terdiri dari sembilan angka yaitu 0,1,2,3,4,5,6,7,8,9. Selain sistem penomoran arab ada sistem penomoran lain yang juga sering dipakai, yaitu sistem romawi. Sistem penomoran romawi menggunakan 7 simbol yang bisa dikombinasikan untuk merepresentasikan angka 1 s.d. 1.000.000. Sismbol-simbol dalam sistem romawi yaitu : I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000.

Contoh : 1973 (Arab) sama dengan MCMLXXIII (Romawi).


Pada artikel berikut ini akan diberikan cara untuk mengkonversi angka romawi kedalam sistem arab. Berikut ini source code nya :

function RomanToArabic(const romanNumber : string) : integer ;
 const
   romanChars = 'IVXLCDMvxlcdm?!#' ;
   decades : array [0..8] of integer = (0, 1, 10, 100, 1000, 

                    10000, 100000, 1000000, 10000000) ;
   OneFive : array [boolean] of byte = (1, 5) ;
 var
   newValue, oldValue : integer ;
   cIdx, P : byte ;
 begin
   result := 0;
   oldValue := 0 ;
   for cIdx := Length(romanNumber) downto 1 do
   begin
     P := Succ(Pos(romanNumber[cIdx], romanChars)) ;
     newValue := OneFive[Odd(P)] * decades[P div 2] ;
     if newValue = 0 then
     begin
       result := -1;
       Exit;
     end ;
     if newValue < oldValue then newValue := - newValue ;
     Inc(result, newValue) ;
     oldValue := newValue
   end ;
 end;
Catatan : fungsi RomanToArabic akan mengembalikan nilai -1 jika parameter "romanNumber" bukan angka dalam format romawi (contoh "MIXKIX" adalah bukan angka romawi).
Source : delphi.about.com
Selengkapnya...

Cara Membuat Warna Baris Selang seling Di cxGrid

Untuk mempercantik tampilan cxGrid, kita bisa melakukan perubahan warna baris-barisnya. Kita bedakan warna antara baris ganjil dan genap. Untuk melakukan ini, ikuti langkah-langkah berikut :
1.       Masukkan komponen cxGrid

-          Set alignmentnya menjadi alTOP

-          Ganti viewnya yang tadinya DBTable menjadi Table (jika anda akan langsung mengkases data ke database bisa tetap menggunakan DBTable), namakan dengn : cxGridTableGrid1TableView1

-          Tambahkan tiga kolom mis :  Nama Barang, Harga








2.       Masukkan komponen cxStyleRepository
-          Klik Kanan > Edit
-          Tambahkan dua style dengan klik tombol Add
-          Namakan kedua style tersebut dengan cxStyleRepEven dan cxStyleRepOdd
-          Setting warna baris dari masing-masing style tersebut mis untuk cxStyleRepEven Color > clInactiveBorder, cxStyleRepOdd Color > clMoneyGreen
-          Klik tombol close


3.       Klik table yang ada di cxGrid
-          Expand property Style dengan klik tanda  +
-          Set style ContentEvent, pilih cxStyleRepEven
-          Set style ContentOdd, pilih cxStyleRepOdd

4.       Untuk meliha hasilnya, kita harus mengisi table tersebut dengan data. Kita akan isi datanya pada saat form ini dicreate. Untuk melakukan langkah berikut :
-          Double klik di form untuk mengarahan ke method formcreate()
-          Isikan baris kode berikut ini :

with cxGridTableGrid1TableView1 do
  begin
    DataController.RecordCount := 5;
    DataController.Values[0,0] := 'Biskuat';
    DataController.Values[0,1] := '500';

    DataController.Values[1,0] := 'Aqua Galon';
    DataController.Values[1,1] := '11500';

    DataController.Values[2,0] := 'Beng-beng';
    DataController.Values[2,1] := '500';

    DataController.Values[3,0] := 'Sabun Lux';
    DataController.Values[3,1] := '1500';

    DataController.Values[4,0] := 'Biskuit';
    DataController.Values[4,1] := '22500';
  end;

5.       Lihat tampilannya



Selamat berkreasi
Selengkapnya...

About Delphi: The Width Of The Drop Down List For TComboBox




Sizing TComboBox Drop Down List Width - No Cut Off
When a combo box is in dropped down state Windows draws a list box type of control to display combo box items for selection. When the length (of a string) of items exceeds the width of the combo box, the items are displayed as cut-off!

Change the Default Application Icon for a Console Mode Delph
For a normal GUI application you can change the application icon using Project - Options - Application - Application Settings - Icon. For console mode applications this section is disabled - and thus all console mode application have a default icon.

Set Of String in Delphi? Yes! Union, Intersection and Difference For String Lists.
in Delphi TIPS :: In Delphi, sets or set types allow you to do set type operations like union, intersection and difference on a set of ordinal values. A set... Read more

Learn Delphi for .NET
Articles and technical information that will help you start developing with and master Delphi for .NET. Find out about the new IDE, Ado.Net, Asp.Net, ECO, IL, aspx, XML Web Services, msil, ...


Selengkapnya...

About Delphi: Set Of String: implemented!




Set Of String in Delphi? Union, Intersection and Difference!
A set is a collection of ordinal values. The values in a set have no order and it makes no sense to have a value twice (or more times) in a set. Since strings are not ordinal types you cannot have set of string declarations. Or, can you?

Implementing StartsText With SubText As Pattern - When Pattern Is A Regular Expression!
in regex :: For a relative file path like "abcdeffile.txt" I need to check if the file is located in the "abcdef" folder (or in any of its sub folders).... Read more

Use TFile Delphi Record To Encrypt or Decrypt A File
in Files and Folders ::A member of the Delphi Programming Forum in a post titled "RTF File encryption" is asking for some help in encrypting RTF documents. Starting with Delphi 2010,... Read more

Delphi Programming - Inside and Out
Delphi language, IDE tips, techniques and articles. Every programming aspect of Delphi is uncovered: OOP, Threading, File IO, RTL, VCL ...


Selengkapnya...

About Delphi: StartsText Regular Expression Patterned





Implementing StartsText With SubText As Pattern
For a relative file path like "\abc\def\file.txt" I need to check if the file is located in the "\abc\def" folder (or in any of its sub folders). Let's call this "\abc\def" a predefined path. Note that I am not interested in the drive nor the path complexity before "\abc\def".

Use TFile Delphi Record To Encrypt or Decrypt A File
in Files and Folders ::A member of the Delphi Programming Forum in a post titled "RTF File encryption" is asking for some help in encrypting RTF documents. Starting with Delphi 2010,... Read more

Implementing the OnBeforeCreate and OnAfterCreate Events for Delphi Forms
in Delphi Forms :: The TForm's OnCreate event is called when the form is created. Usually, you would write an OnCreate event handler to perform special processing when the... Read more

Advanced Delphi Windows / Shell / API / Graphics / OLE Programming
A simple understanding of Delphi is fine when you create applications for home use. Once you start building real-world applications you'll start looking for ways to solve more complex tasks - and Delphi will have all the answers!



Selengkapnya...

DelphiFeeds : Delphi Spring, Mocks and how to use them: some links


Posted: 27 Sep 2011 02:00 AM PDT
Now that there is Spring and Mocks for Delphi, it is time to post a few links: Nick Hodges indicating he is going to write more about Delphi Spring and Mocks Nick Hodges' first article (in a 5 series part) on Delphi Spring framework, Dependency Injection and Unit testing Vincent Parret on ...
Posted: 27 Sep 2011 12:54 AM PDT
in regex :: For a relative file path like "\abc\def\file.txt" I need to check if the file is located in the "\abc\def" folder (or in any of its sub folders). Let's call this "\abc\def" a predefined path. Note that I am not interested in the drive nor the path complexity before "\abc\def". How to ...
Posted: 26 Sep 2011 11:26 PM PDT
During the world tour, lots of Delphi developers ask me if the Delphi Certification Program is up to date with the Delphi XE2 release, the answer is YES. The certification program tests your knowledge in Delphi, we recommend you to use Delphi XE or XE2 release in order to be prepared to answers ...
Posted: 26 Sep 2011 10:55 PM PDT
If you didn't have the opportunity to see all of the great RAD Studio XE2 new features during the world tour, take sometime today and join us for one of the three live webinars.   First webinar – 6:00am PDT / 9:00am EDT / 3:00pm CET Second webinar – 11:00am PDT / 2:00pm EDT ...
Posted: 26 Sep 2011 09:10 PM PDT
In deze Nederlandstalige Delphi XE2 Clinic staan de essentiƫle nieuwe features van Delphi XE2 centraal, met ondersteuning voor Win32, Win64 en Mac OS X.
Posted: 26 Sep 2011 08:00 PM PDT
Hope you like these classics from the early Borland era: The 1985 Turbo Pascal Version 3.0 Reference Manual Jan 1985 Turbo Tutor_Version_1.0: a Self-Study Guide on Turbo Pascal Jun 1987 Borland Byte Ad on Eureka: The Solver Aug 1998 Borland Byte Ad on the Adventures of Turbo Man Nov 1998 Borland ...
Posted: 26 Sep 2011 05:12 PM PDT
Awhile back I wrote about music technology being one of the areas pushing new user interface\interaction technologies, such as the Kinect, and the Wii before it. Well, I'm a little behind on this one, but this video preview of AudioGL is another example, this time in terms of 3D UI. Apart ...
Posted: 26 Sep 2011 01:38 PM PDT
I just read this fascinating article in The New Yorker about "coaching," and how it might apply to professionals like us. It's a little lengthy, but it's an excellent read. Please take a few minutes to read it, and then if you feel so inclined, here are some questions that I ...
Posted: 26 Sep 2011 01:21 PM PDT
I am finally back in my Scotts Valley office today after three weeks on the road visiting with great developers on three continents and on the Internet.  Many thanks to all of you that spent your valuable time with me and all of the other RAD Studio XE2 World Tour evangelists.  Just want to remind ...
Posted: 26 Sep 2011 12:53 PM PDT
This is only going to be a short entry just to inform that the Delphi IDE Theme Editor and the WMI Delphi Code Creator are now compatible with Delphi XE2.
Posted: 26 Sep 2011 07:15 AM PDT
It's possible that Structural Highlighting is Castalia's most popular feature. It's certainly one of the first things that you notice when you try Castalia for the first time, and one of the things that people tell me over and over again they love. Of course, code formatting can be ...
Selengkapnya...

About Delphi: File Encryption / Decryption





Use TFile Delphi Record To Encrypt or Decrypt A File
Starting with Delphi 2010, the RTL includes the "ioutils.pas" unit hosting dozens of file and folder related functions grouped into TFile, TDirectory, TPath and alike classes (records to be more precise).

Implementing the OnBeforeCreate and OnAfterCreate Events for Delphi Forms
in Delphi Forms :: The TForm's OnCreate event is called when the form is created. Usually, you would write an OnCreate event handler to perform special processing when the... Read more

Crypting Your INI (Configuration) Files
in INI Files :: In most of my applications I'm using INI files to store configuration options. INI files are text based documents with a simple structure. A user can open... Read more

Getting Started with Delphi
So, you want to learn Delphi? This is the right place: Delphi tutorials and articles for beginners.



Selengkapnya...