Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

Rob McBean

@Rob McBean
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Use DLL in VBasic
    R Rob McBean

    This is kind of lengthy... but this is how i do it. First, create a dll project in vcc. Select MFC AppWizard(DLL). Select Regular DLL. Does'nt matter whether MFC is static or shared. Create a .cpp file for your function you want to call. You will have to create "C" style function because you cannot do external linkage to vb with C++ classes. This example is a function called Function123. It takes a string you can modify and returns a UINT. prototype: extern "C" UINT __stdcall Function123 (LPSTR lpszBenefits); the body looks like this: extern "C" UINT __stdcall Function123(LPSTR lpszBenefits) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // This line is important!!! // do something return someUINT; } Now find the .def file that vc created. It should be under source files where the rest of the cpp files are. Add the following entry to the file: Function123 @1 The @1 indicates that this is function #1 to be exported. If you add more functions then they should be as @2,@3 etc. Compile your project and produce the DLL. Now, in VB: Add this line at the top of a module file: Private Declare Function vbfunctionname Lib "EChartPatients.dll" Alias "Function123" (ByVal strName As String) As Long Now in your module to use this function: ... dim x as integer dim y as string x= vbfunctionname(y) ... The DLL you created does not have to be linked to the vb exe in any way except that it has to be in the executable path, or, you have to hardcode the path + name in the vb declare statement. Warning: Initialize your vb string to the max length required prior to sending it into the dll.

    Visual Basic question c++ help

  • How do I pass a structure to a function??
    R Rob McBean

    I see the confusion here...Passing by reference in C means to pass a pointer which means that the called function can modify it. Passing by value means you are passing a copy of the variable. C++ introduced the concept of the reference type. A reference is like a pointer, but unlike a pointer is must be bound to a specific variable. K&C have a very good explanation of pass by value/reference and pointers, however that was written before c++ came along. See Stroustrups book on C++ for an explanation of C++ references. Reference types do not access their members with -> but with . pass structure by reference in c: main { somestruct x; function(&x) } function( somestruct* y) { y->member = ... } same thing in C++ main { somestruct x; somrstruct& y = x; function(y) } function(somestruct& ref) { y.member = ... }

    C / C++ / MFC question

  • Prophet of doom
    R Rob McBean

    Daniel Turini wrote: Here in my office there is a girl that believes in any "magic" or "esoteric" BS she can gets her hands on I love chicks like that.:rose:

    The Lounge help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups