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. C / C++ / MFC
  4. DLL PROBLEM IN vb front end after calling the dll written in win32 application

DLL PROBLEM IN vb front end after calling the dll written in win32 application

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingtutorial
5 Posts 4 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.
  • P Offline
    P Offline
    phijophlip
    wrote on last edited by
    #1

    Private Declare Function concat Lib "d:\StringConcat1.dll" (ByVal Text1 As String, ByVal Text2 As String) As String Private Sub Command1_Click() Text3.Text = concat(Text1.Text, Text2.Text) a = Len(concat(Text1.Text, Text2.Text)) MsgBox a End Sub The function of the vb code is given below. The form has three text fields a) The first text field , enter the first string b) The second text field , enter the second string c) The third text field, concatation of the two string i.e result of the two strings is shown in third text field d) One Command button at the bottom of the form. When we call "StringConcat1.dll" dll the value entered through the two text fields is send as a argument by value to the dll and Concatenation of the strings is done in C++ . the dll code is given below "test.cpp" #include char* __stdcall concat(char *string1 , char *string2) { return strcat(string1,string2); } the def is given "test.def" LIBRARY StringConcat1 EXPORTS concat @1 When I debug the code , the Concatenation is done in C++ but when the result is given to vb code ie front end only the first string that is entered in the first text is shown only as the output in the third text field. for example text1 : india text2 : people result text3 : india ( but the result should be indiapeople after the concatenation is done in C++(i.e dll does the function for concatenation , but the result shown is here is only "india"). Kindly note the point: the C++ code works perfectly. After computation ie Concatenation , the result is not shown in the vb code only text1 input is shown in text3 field. Can any help me in this matter From Phijo Philip

    C E V 4 Replies Last reply
    0
    • P phijophlip

      Private Declare Function concat Lib "d:\StringConcat1.dll" (ByVal Text1 As String, ByVal Text2 As String) As String Private Sub Command1_Click() Text3.Text = concat(Text1.Text, Text2.Text) a = Len(concat(Text1.Text, Text2.Text)) MsgBox a End Sub The function of the vb code is given below. The form has three text fields a) The first text field , enter the first string b) The second text field , enter the second string c) The third text field, concatation of the two string i.e result of the two strings is shown in third text field d) One Command button at the bottom of the form. When we call "StringConcat1.dll" dll the value entered through the two text fields is send as a argument by value to the dll and Concatenation of the strings is done in C++ . the dll code is given below "test.cpp" #include char* __stdcall concat(char *string1 , char *string2) { return strcat(string1,string2); } the def is given "test.def" LIBRARY StringConcat1 EXPORTS concat @1 When I debug the code , the Concatenation is done in C++ but when the result is given to vb code ie front end only the first string that is entered in the first text is shown only as the output in the third text field. for example text1 : india text2 : people result text3 : india ( but the result should be indiapeople after the concatenation is done in C++(i.e dll does the function for concatenation , but the result shown is here is only "india"). Kindly note the point: the C++ code works perfectly. After computation ie Concatenation , the result is not shown in the vb code only text1 input is shown in text3 field. Can any help me in this matter From Phijo Philip

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      It's much more complicated than you think ! VB and C++ don't have the same format for string representation. It works the way you did to pass string from VB to C++ but the other way is more complicated (the return of the string). But my question is: why do you want to call a dll to concatenate two strings :wtf: ? What is the exact purpose of this dll ? why don't you simply concatenate the two strings in VB ?


      Cédric Moonen Software developer
      Charting control

      1 Reply Last reply
      0
      • P phijophlip

        Private Declare Function concat Lib "d:\StringConcat1.dll" (ByVal Text1 As String, ByVal Text2 As String) As String Private Sub Command1_Click() Text3.Text = concat(Text1.Text, Text2.Text) a = Len(concat(Text1.Text, Text2.Text)) MsgBox a End Sub The function of the vb code is given below. The form has three text fields a) The first text field , enter the first string b) The second text field , enter the second string c) The third text field, concatation of the two string i.e result of the two strings is shown in third text field d) One Command button at the bottom of the form. When we call "StringConcat1.dll" dll the value entered through the two text fields is send as a argument by value to the dll and Concatenation of the strings is done in C++ . the dll code is given below "test.cpp" #include char* __stdcall concat(char *string1 , char *string2) { return strcat(string1,string2); } the def is given "test.def" LIBRARY StringConcat1 EXPORTS concat @1 When I debug the code , the Concatenation is done in C++ but when the result is given to vb code ie front end only the first string that is entered in the first text is shown only as the output in the third text field. for example text1 : india text2 : people result text3 : india ( but the result should be indiapeople after the concatenation is done in C++(i.e dll does the function for concatenation , but the result shown is here is only "india"). Kindly note the point: the C++ code works perfectly. After computation ie Concatenation , the result is not shown in the vb code only text1 input is shown in text3 field. Can any help me in this matter From Phijo Philip

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #3

        Before returning, try this. char* __stdcall concat(char *string1 , char *string2) { strcat(string1,string2); **AfxMessageBox(string1)** **AfxMessageBox(string1);**oops sorry not like this. return strcat(string1,string2); return(string1); } And tell me what you get. also a = Len(concat(Text1.Text, Text2.Text)) MsgBox a What's the length of the resultant text? I think it could only be of the first string's length. (as you get only the 1st string as the result). Ok tell me what you got in the AfxMessageBox, If it's not an MFC DLL, try using MessageBox.. And Also remove the BOLD SHOUT please...:(


        --[V]-- [My Current Status] -- modified at 6:09 Monday 12th June, 2006

        1 Reply Last reply
        0
        • P phijophlip

          Private Declare Function concat Lib "d:\StringConcat1.dll" (ByVal Text1 As String, ByVal Text2 As String) As String Private Sub Command1_Click() Text3.Text = concat(Text1.Text, Text2.Text) a = Len(concat(Text1.Text, Text2.Text)) MsgBox a End Sub The function of the vb code is given below. The form has three text fields a) The first text field , enter the first string b) The second text field , enter the second string c) The third text field, concatation of the two string i.e result of the two strings is shown in third text field d) One Command button at the bottom of the form. When we call "StringConcat1.dll" dll the value entered through the two text fields is send as a argument by value to the dll and Concatenation of the strings is done in C++ . the dll code is given below "test.cpp" #include char* __stdcall concat(char *string1 , char *string2) { return strcat(string1,string2); } the def is given "test.def" LIBRARY StringConcat1 EXPORTS concat @1 When I debug the code , the Concatenation is done in C++ but when the result is given to vb code ie front end only the first string that is entered in the first text is shown only as the output in the third text field. for example text1 : india text2 : people result text3 : india ( but the result should be indiapeople after the concatenation is done in C++(i.e dll does the function for concatenation , but the result shown is here is only "india"). Kindly note the point: the C++ code works perfectly. After computation ie Concatenation , the result is not shown in the vb code only text1 input is shown in text3 field. Can any help me in this matter From Phijo Philip

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          I suggest you would go for an ATL (COM)DLL if you want to integrate you C++ code into VB. Which would be hassle free ;)


          --[V]-- [My Current Status]

          1 Reply Last reply
          0
          • P phijophlip

            Private Declare Function concat Lib "d:\StringConcat1.dll" (ByVal Text1 As String, ByVal Text2 As String) As String Private Sub Command1_Click() Text3.Text = concat(Text1.Text, Text2.Text) a = Len(concat(Text1.Text, Text2.Text)) MsgBox a End Sub The function of the vb code is given below. The form has three text fields a) The first text field , enter the first string b) The second text field , enter the second string c) The third text field, concatation of the two string i.e result of the two strings is shown in third text field d) One Command button at the bottom of the form. When we call "StringConcat1.dll" dll the value entered through the two text fields is send as a argument by value to the dll and Concatenation of the strings is done in C++ . the dll code is given below "test.cpp" #include char* __stdcall concat(char *string1 , char *string2) { return strcat(string1,string2); } the def is given "test.def" LIBRARY StringConcat1 EXPORTS concat @1 When I debug the code , the Concatenation is done in C++ but when the result is given to vb code ie front end only the first string that is entered in the first text is shown only as the output in the third text field. for example text1 : india text2 : people result text3 : india ( but the result should be indiapeople after the concatenation is done in C++(i.e dll does the function for concatenation , but the result shown is here is only "india"). Kindly note the point: the C++ code works perfectly. After computation ie Concatenation , the result is not shown in the vb code only text1 input is shown in text3 field. Can any help me in this matter From Phijo Philip

            V Offline
            V Offline
            Viorel
            wrote on last edited by
            #5

            The strcat(string1, string2) looks suspicious: since the strcat function stores the result of concatenation in the first string, the string1 passed from Visual Basic may not have enough room for concatenated destination string.

            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