Solved

how to create component at run time?

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

718 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