473,626 Members | 3,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating objects (by assignment) in VB6

I know this is a VB.Net ng. But hopefully, someone remembers some
classic (VB6) coding - besides I've not had any response when I posted
this to the VB6 specific ng.

I wrote a C++ librray that I want to use in VB6. I have exported a C API
(via a win32 DLL) that may be used in VB6 using the 'Declare Function'
syntax.

However, I need to group related functions together (in VB6), by
wrapping them together in a VB6 class.

Assuming CreateNewObject is an exposed C function that returns a pointer
to a C++ object is declared in VB6 as follows:

Declare function CreateNewObject lib "mylib" () as long

Using the plain API (without wrapping the C++ objects in a VB6 class), I
would have code that looks like this :

dim lngPtr as long
lngPtr = CreateNewObject () 'calls Dll function
With the exposed C functions wrapped up in VB6 classes, the code looks
something like this:

dim objVBWrapper as MyVBWrapperClas s

// which of these statements are correct?
objVBWrapper = CreateNewObject () //OR
Set objVBWrapper = CreateNewObject ()

The key difference here is that I am creating the object by assignment.
Since there is no explicit copy constructor in VB6 I'm not sure how this
may be implemented. Ideas please ...
Jun 24 '07 #1
1 2212
"Bartholome w Simpson" <12**********@t errace.comschri eb
I know this is a VB.Net ng. But hopefully, someone remembers some
classic (VB6) coding - besides I've not had any response when I
posted this to the VB6 specific ng.

I wrote a C++ librray that I want to use in VB6. I have exported a C
API (via a win32 DLL) that may be used in VB6 using the 'Declare
Function' syntax.

However, I need to group related functions together (in VB6), by
wrapping them together in a VB6 class.

Assuming CreateNewObject is an exposed C function that returns a
pointer to a C++ object is declared in VB6 as follows:

Declare function CreateNewObject lib "mylib" () as long

Using the plain API (without wrapping the C++ objects in a VB6
class), I would have code that looks like this :

dim lngPtr as long
lngPtr = CreateNewObject () 'calls Dll function
With the exposed C functions wrapped up in VB6 classes, the code
looks something like this:

dim objVBWrapper as MyVBWrapperClas s

// which of these statements are correct?
objVBWrapper = CreateNewObject () //OR
Set objVBWrapper = CreateNewObject ()

The key difference here is that I am creating the object by
assignment. Since there is no explicit copy constructor in VB6 I'm
not sure how this may be implemented. Ideas please ...
VB6 objects are COM/ActiveX objects. The C++ objects are (normally) not, so
you can not assign a pointer to a C++ object to a VB object variable. The
infrastructure is different.

The two options you have is either write COM objects in C++, or export
native functions from C++ and wrap them into a VB6 class. You did export
functions, but what you are trying here is using the members of a C++
object. There is no built-in way to access a C++ object from VB6.
Armin

Jun 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1410
by: ajit goel | last post by:
Hi; I have a question which respect to initialising and creating objects in loops.Here are the 2 scenarios: 1. ############################################################################### for (int i=0;i<5;i++) { object a= new object();
4
326
by: Wraith Daquell | last post by:
Hello all. I am working on a project that involves an Office-like interface; that is, the user will be able to create objects such as textareas and be able to resize, move, manipulate, etc. them. I am NOT asking someone to go out of their way and write such a class for me, but I was wondering if anyone knows of any *free* classes or libraries that are available to do such a thing. Also, any tips or tricks would be most appreciated. I...
2
1599
by: ikl | last post by:
When creating a list of objects of the same class, what should be concerned to decide if using "new" or not? Since how many number of the objects are unknown until runtime, probably it is not a good idea to create like: class A; A a; .... How would like to code this? Thanks!
0
1049
by: Alexandre | last post by:
hey this is the error im getting : --> Cannot widen from target type to primitive type. this line produces the error : temp = o.GetType().InvokeMember("", BindingFlags.CreateInstance, null, null, null); ==============================================
1
1350
by: chris | last post by:
I know I've asked this before, but I didn't really get an answer and I bet it's because I didn't explain myself very well. Here goes again. I have this code: Dim arrData(intNoOfRows, intNoOfColumns) As Object Dim intR As Integer For intC As Integer = 0 To intNoOfColumns - 1
3
1591
by: Richard Thornley | last post by:
Hello, I need some clarification in creating objects. Consider the following code... (note: The function InitializeListCombo initializes the combobox) Private daLists As New OleDbDataAdapter
5
1540
by: fireball | last post by:
please help newbie I need to create a lot of objects the same type (let's say: schemas) I wish to use paramerized block in loop to do so. - how to put names of my objects to such control-flow? belss you for help
6
5454
by: RSH | last post by:
Hi, i have a situation where I need to dynamically create objects in a loop. My question surrounds intantiation naming in such a scenerio. Below is a snippet that is basically hardcoding each object. My problem is that I would like to create the objects dynamically but I can't figure out how to do it How would I go about dynamically creating the required objects so that I could be using anywhere from 2 - 10 etc. ?
31
3178
by: JoeC | last post by:
I have read books and have ideas on how to create objects. I often create my own projects and programs. They end up getting pretty complex and long. I often use objects in my programs they are some of the most powerful programming tools I have found. Often times as my program grows so do my objects. Often times I look back and see that my objects could be broken down int several smaller more re-usable module pieces of code. Is it a...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.