|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming | |
Visual Basic / Visual C++ .dll question
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | ||||||||||||
|
Audiophile
![]() |
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.
|
||||||||||||
|
|
|
|
|
#2 (permalink) | |||
|
Performance
![]() |
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.. ![]()
Last edited by linskingdom : 06-30-09 at 07:43 AM |
|||
|
|
|
|
#3 (permalink) | ||||||||||||
|
Audiophile
![]() |
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.
|
||||||||||||
|
|
|
|
|
#4 (permalink) | ||||||||||||
|
Audiophile
![]() |
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?
|
||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|