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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.Fiel dsByName[' Field1'].A sString)
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.Fiel dsByName[' Field1'].A sString);
MatchItems.add(Query.Field sByName['F ield2'].As String)
Query.Next;
end;
Then you can do this:
edit1.text := MatchItems[Combo.ItemIndex ];
Cheers,
Raymond.
while not Query.eof do
begin
Combo.items.add(Query.Fiel
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.Fiel
MatchItems.add(Query.Field
Query.Next;
end;
Then you can do this:
edit1.text := MatchItems[Combo.ItemIndex
Cheers,
Raymond.
ASKER
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
great answer
thank you
Glad I could help!
Cheers,
Raymond.
Cheers,
Raymond.
edit1.text := TranslateValue(ComboBox);
Cheers,
Raymond.