Link to home
Start Free TrialLog in
Avatar of ElvasLion
ElvasLion

asked on

Migrating from vb to Delphi III

Here i am again!!!
This time a want to know how can i write global functions and procedures to use in diferent projects, i mean in vb i woul´d create a module and then i woul´d add that module to any project i wanted.
i also need to know how can i pass controls like labels and combos to those procedures.
i need also a to know if there is any function that can count the ocurrencys of a char or a substring, in a string ex. S:='okokok' strcount???(s,'k') ---> shoul´d return 3
thanks.

P.S.- i still can´t find any proprety in the comboboxes where i coul´d hide a value or a string
ex: i have a combo with 2 items
apple in index 0
peach in index 1
i want to hide the value 200 in apple and 150 in peach, then when i select the apple for example, i woul'd be able
to do this edit1.text:=combobox1.?????
and then it appeared in edit1.text the value 200

ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwilson032697
rwilson032697

Item 4 should read:

  edit1.text := TranslateValue(ComboBox);

Cheers,

Raymond.

Avatar of ElvasLion

ASKER

yeap i think you´re right...they are 4 question(:

in 1,2 and 3 you´re answer is ok, but in question 4 i still don´t know how to store that value in the combo, because if i understood(is this word well written???) your answer, the combo gets the values from the table and i want to avoid that, to save time, because i will load the combo at the begining and thn i wont have to go to the table anymore.
please reply fast so that i can give you the points.
thanks
If you are filling the combo from a query or table like this:

while not Query.eof do
  begin
    Combo.items.add(Query.FieldsByName['Field1'].AsString)
    Query.Next;
  end;

Then you could build a list of the other values like this (where MatchItems is a TStringList):

while not Query.eof do
  begin
    Combo.items.add(Query.FieldsByName['Field1'].AsString);
    MatchItems.add(Query.FieldsByName['Field2'].AsString)
    Query.Next;
  end;

Then you can do this:

edit1.text := MatchItems[Combo.ItemIndex];

Cheers,

Raymond.

i won´t rate this question above A because there is no way to do it, but you just saved me 1 day of research to find the better method.
great answer
thank you
Glad I could help!

Cheers,

Raymond.