Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 06-30-09   #1 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default Visual Basic / Visual C++ .dll question

What's the best way to use my Visual C++ code with my Visual Basic code?

I've read guides online, but some aspects aren't clear.

My code generates random numbers, tags those numbers, and converts the tags + numbers into a string of data. To get the random numbers, I have to call srand(time(NULL)) in my int main(), create a class, and run the process of that class to generate the random numbers. There is also a counter that keeps track of how many strings have been generated.

I need Visual Basic to send this data to a serial port. In VB I have a function:

WriteStringToPort(data)

Could someone tell me how I can generate my string to use in the above function? I need to constantly keep sending strings until the user commands the program to stop.
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Old 06-30-09   #2 (permalink)
Performance
 
linskingdom's Avatar
 
intel nvidia

Join Date: Jun 2007
Location: In Office
Posts: 13,419

Rep: 3340 linskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a gurulinskingdom is a guru
Unique Rep: 1406
Trader Rating: 7
Default

There are many ways to do so. Depending on which version of VB, you can

1. If that c++ dll is COM interface, then you can create a warp by adding the c++ dll reference to your VB project for vb.net, then call the function as usual. In vb6, you can use createobject to create an instance and then call that function.
2. Standard api call.
Public Declare Function WriteStringToPort Lib "yourdllname" Alias "iftheWriteStringToPortHasSameName" (ByVal data As String) As Long ' use your whatever the data type you want to return.
Once you have this declaration, then call the WriteStringToPort function as usual in VB code. In vb.net, you can use reflection to emit the function also.
__________________
Push to the limit one more time..


System: QD65D45
CPU
E8500
Motherboard
Gigabyte EP45-UD3P

Last edited by linskingdom : 06-30-09 at 07:43 AM
linskingdom is offline Overclocked Account linskingdom's Gallery   Reply With Quote
Old 06-30-09   #3 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default

This my problem. I'm inexperienced and each simple instruction leads to multiple things I've never seen or heard of then I lose sight of what I'm actually trying to do. For instance, I have no clue about "COM interface" "warp" "use reflection to emit."

Does Visual Studio have better support? It's infuriating spending hours on so many guides and tutorials with none of them working and trying to fix multiple errors with solutions that assume you've spent a year with the program.

Even the getting started guide is useless to a new user.
http://msdn.microsoft.com/en-us/libr...97(VS.80).aspx


Is there anything better than MSDN for learning this stuff? All of the guides seem overly complex, and they are all written for VB6. I can't even get something simple like an addition function to work via dll.

The only experience I have is coding in C++ in Dev-C++. I'm having a lot of trouble making sense of VB lingo in articles. Even when watching VB tutorials online, they assume you are fluent in C and Basic but can't operate a mouse.
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Old 06-30-09   #4 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default

EDIT:

Is there a way to do this without .dll? In my C++ program I create an char* array to hold my data string. So the address of my data is constant and of a fixed size. Is it possible to run my C++ program while running a seperate VB program that accesses the memory where the string is stored?
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 01:09 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.10987 seconds with 8 queries