Solved

how to create component at run time?

Posted on 2001-06-14
4
131 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
[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
  • 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

733 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