How To create an instance of a Class in Visual Basic

Reply

Join Date: Sep 2007
Posts: 6
Reputation: Augustin is an unknown quantity at this point 
Solved Threads: 0
Augustin Augustin is offline Offline
Newbie Poster

How To create an instance of a Class in Visual Basic

 
0
  #1
Oct 11th, 2007
HI

I want to create an Instance of Class(Object) In Visual Basic.Using "Create Object " Syntax. please refer attached CPP & header File for the class COMOutput. How can i create an object for this COMOutput Class in Visual Basic. And I need to access the Functions Defined in The COMOutput.Cpp. PLease Help me.Thanks

Augustin
Attached Files
File Type: cpp COMOutput.cpp (756 Bytes, 4 views)
File Type: h COMOutput.h (1.2 KB, 1 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: How To create an instance of a Class in Visual Basic

 
0
  #2
Oct 11th, 2007
You need to compile this cpp class as a .DLL and then refer this dll in your VB propject.

You are good to go.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: How To create an instance of a Class in Visual Basic

 
0
  #3
Oct 11th, 2007
Create a dll file using VC++ Win32 Dynamic-Link Library Project type.
Compile the dll and register it in system32.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 6
Reputation: Augustin is an unknown quantity at this point 
Solved Threads: 0
Augustin Augustin is offline Offline
Newbie Poster

Re: How To create an instance of a Class in Visual Basic

 
0
  #4
Oct 12th, 2007
Hi Binoj

I have tried to create a DLL with the C++ & the Header file. But i got Errors While Creating . As i have No idea on What Header Files to be included for the Errors. Can u help me on that
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,082
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: How To create an instance of a Class in Visual Basic

 
0
  #5
Oct 12th, 2007
.CPP and .H files can't be directly referenced fronm VB. compile to .DLL file and then instanceate in VB.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 6
Reputation: Augustin is an unknown quantity at this point 
Solved Threads: 0
Augustin Augustin is offline Offline
Newbie Poster

Re: How To create an instance of a Class in Visual Basic

 
0
  #6
Oct 12th, 2007
HI debasis,

I have tried to create a DLL with the C++ & the Header file. But i got Errors While Creating . As i have No idea on What Header Files to be included for the Errors. Can u help me on that ..please try to create a DLL with the files i have attached & can u give me a feedback on Errors....Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1
Reputation: hereisanswer is an unknown quantity at this point 
Solved Threads: 0
hereisanswer hereisanswer is offline Offline
Newbie Poster

Re: How To create an instance of a Class in Visual Basic

 
0
  #7
Oct 12th, 2007
create a DLL.register
to to command prompt and type
c:>regsvr32 <complete path of DLL>

open your vb project. go to project-refrences- add the DLL from the list

now create a object
dim obj as new <nameof DLL.ClassName>

now u can use the function

hope this will work
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: How To create an instance of a Class in Visual Basic

 
0
  #8
Oct 12th, 2007
Originally Posted by debasisdas View Post
.CPP and .H files can't be directly referenced fronm VB. compile to .DLL file and then instanceate in VB.
Please see the post before you post redundant replies.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: How To create an instance of a Class in Visual Basic

 
0
  #9
Oct 12th, 2007
Originally Posted by hereisanswer View Post
create a DLL.register
to to command prompt and type
c:>regsvr32 <complete path of DLL>

open your vb project. go to project-refrences- add the DLL from the list

now create a object
dim obj as new <nameof DLL.ClassName>

now u can use the function

hope this will work
I think thats what i posted in my first post. Please take time to read before posting.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 6
Reputation: Augustin is an unknown quantity at this point 
Solved Threads: 0
Augustin Augustin is offline Offline
Newbie Poster

Re: How To create an instance of a Class in Visual Basic

 
0
  #10
Oct 17th, 2007
Originally Posted by debasisdas View Post
.CPP and .H files can't be directly referenced fronm VB. compile to .DLL file and then instanceate in VB.

I have tried to create a DLL with the C++ & Header file. It is using ATL/COM Model ..So if i tried to create a DLL i am getting Errors. How to create it Properly. PLease can you refer the files Attached COMOutput.h COMOutput.Cpp
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC