DLL PROBLEM IN vb front end after calling the dll written in win32 application
-
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
-
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
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 -
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
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. alsoa = 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 usingMessageBox
.. And Also remove the BOLD SHOUT please...:(
--[V]-- [My Current Status] -- modified at 6:09 Monday 12th June, 2006
-
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
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]
-
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