Solved

how to create component at run time?

Posted on 2001-06-14
4
130 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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