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
  1. Home
  2. General Programming
  3. Visual Basic
  4. byref t ype mismatch

byref t ype mismatch

Scheduled Pinned Locked Moved Visual Basic
debugginghelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    I have the C dll:

    #include
    #include

    int _stdcall CallMe(int *a, int *b)

    {
    char ab[20];

    sprintf(ab,"The value of a is %d \n",a);
    MessageBox (NULL, ab, "Test DLL", MB_OK);
    b = a;

    return 0;

    }

    with the .def file:

    LIBRARY builderDll
    EXPORTS
    CallMe (int *a, int* b) @1

    I call this from VB as follows:

    Private Declare Function CallMe Lib "C:\PMARModif\builderDll\Debug\builderDll.dll" (ByVal a As Long, ByRef b As Long) As Long
    Private Sub Command1_Click()

    Dim a As Integer
    Dim b As Integer
    a = 10

    CallMe a, b

    Form1.Print b
    End Sub

    When I try to run I get a byref argument type mismatch pointing at b Appreciate your help, ns

    N 1 Reply Last reply
    0
    • N ns

      I have the C dll:

      #include
      #include

      int _stdcall CallMe(int *a, int *b)

      {
      char ab[20];

      sprintf(ab,"The value of a is %d \n",a);
      MessageBox (NULL, ab, "Test DLL", MB_OK);
      b = a;

      return 0;

      }

      with the .def file:

      LIBRARY builderDll
      EXPORTS
      CallMe (int *a, int* b) @1

      I call this from VB as follows:

      Private Declare Function CallMe Lib "C:\PMARModif\builderDll\Debug\builderDll.dll" (ByVal a As Long, ByRef b As Long) As Long
      Private Sub Command1_Click()

      Dim a As Integer
      Dim b As Integer
      a = 10

      CallMe a, b

      Form1.Print b
      End Sub

      When I try to run I get a byref argument type mismatch pointing at b Appreciate your help, ns

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      at first glance, i would say that you're passing in long when the function takes int ?????? Notorious SMC


      The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
      Get your facts first, and then you can distort them as much as you please Mark Twain

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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