Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Migrating from vb to Delphi III

Posted on 1999-06-27
6
Medium Priority
?
152 Views
Last Modified: 2010-04-06
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

0
Comment
Question by:ElvasLion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1384835
The answers to your FOUR :-) questions:

1. Simply define the procedures in a unit and use that unit in your projects - jsut like VB

2. Like this:

Procedure DoSomethingToCombo(TheCombo : TComboBox)

begin
  ShowMessage(format('Combo %s has a value of %s', [TheCombo.name, TheCombo.Text]);
end;

3. No - You need to write one.

4. You can do this using an ownerdraw combobox. But in this case its much easier just to do this:

  edit1.text := TranslateValue(ComboBox.Text);

where TranslateValue would most likely do an index lookup on the index of the combo value and return the string '200' to the edit box.

Cheers,

Raymond.

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384836
Item 4 should read:

  edit1.text := TranslateValue(ComboBox);

Cheers,

Raymond.

0
 
LVL 1

Author Comment

by:ElvasLion
ID: 1384837
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384838
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.

0
 
LVL 1

Author Comment

by:ElvasLion
ID: 1384839
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
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384840
Glad I could help!

Cheers,

Raymond.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question