Solved

how to create component at run time?

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now