Solved

how to create component at run time?

Posted on 2001-06-14
4
129 Views
Last Modified: 2010-05-02
HI

the problem is i have some questiona in excel.each question has some weightage and algorithm.I have to bring all those things in to vb and have to make each algorithm as logic in vb.All the logic must be put in individual module and finally all should be in one component.How is it possible.please reply me ASAP.
        i know how to bring the data from excel into vb.but i dont know how to create component at runtime.

THANKS IN ADVANCE

VBDOUBT
0
Comment
Question by:vbdoubt
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
gmleeman earned 10 total points
ID: 6190262
To create the component at run time you need to do two main things:

first - Create the component by writing your VB code and compiling the project as an ActiveX or whatever type of component you want.  Make sure that the new component is in the Menu - VB Components list; install if you need to.

Then, you can create an instance of your component at run time using the "New" command in VB.

eg:  Assuming your component is called MY_OBJECT then;

function MyFunction()
  Dim MyNewObject as New MY_OBJECT

  MyNewObject.DoSomething

end function

(Your object name should appear in the list of VB items that appears next to your cursor when you type)

Hope this helps
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6190279
Create an ActiveX DLL. here you could create a class for question-algorithm pair.

Class 1
Class 2
.
.
etc

Declare the functions, subs in the classes which you want to be visible from the calling application, for example
Class 1 could have...

Public Function Create() As String
  Create = ReturnAMessage
End Function

Private Function ReturnAMessage()
   ReturnAMessage = "Hello"
End Function

Let's say the project is compiled as MyDLL.dll

The ActiveX is created by either, setting a reference to MyDLL in Excel VBA and then...

Private myDLLClass1 As MyDLL.Class1
Private myDLLClass1 As MyDLL.Class2
.
.
etc

Private Sub CallDLL()
 Set myDLLClass1 = New MyDLL.Class1
 MsgBox myDLLClass1.Create

End Sub

Of course, I've extremely simplified this.
0
 

Author Comment

by:vbdoubt
ID: 6190317
hi

thanks


the algorithm looks like this
=IF(P14>=100,1000,500) in excel where p14 represents a cell

i want this to be interpreted in vb logic within module.
how can it be done?please explain me
         I have to convert this into vb code consists of if structure.how is it possible

please explain me asap


thanks for advance
m.thiyagarajan
0
 
LVL 3

Expert Comment

by:gmleeman
ID: 6190925
for this algorithm use VB logic, assuming CELL is your destination:

If P14 >= 100 then
   CELL = 1000
Else
   CELL = 500
Endif


Don't forget the words "then" "else" and "endif".

Use F1 (help) alot
Hope this helps
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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