|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
error making function call with multiple parameters to dlldll, but I always get a type mismatch error. Strangely the error does not happen if I pass a single parameter: The two functions in my dll are: Public Function testF(ByVal st As String) As Integer MsgBox st testF = 5 End Function Public Function testF2(ByVal st1 As String, ByVal st2 As String) As Integer MsgBox st1, st2 testF2 = 100 End Function The function calls I make are: 1. --no error---- Dim x, y As Integer x = t.testF("testing") MsgBox "x = " + x 2. --- type mismatch error--- y = t.testF2("one", "two") MsgBox "y= " + y I tried calling the function different ways still I get the error 3. ---type mismatch error----- y = t.testF2(st1:="one ", st2:="two") MsgBox "y= " + y So what am I doing wrong? Should I declare or call the function a different way? Or is it possible that I can only pass one parameter to a dll function? Help please! I wasted days on this already.... Thank you very much.
Show quote
Hide quote
"Sue" <sea_***@hotmail.com> wrote in message Then... you'll hate yourself when you find out where the error is coming news:1142961084.801406.260040@g10g2000cwb.googlegroups.com... > Hi, I am trying to make a function call with multiple parameters to a > dll, but I always get a type mismatch error. Strangely the error does > not happen if I pass a single parameter: > > > Public Function testF2(ByVal st1 As String, ByVal st2 As String) As > Integer > MsgBox st1, st2 > testF2 = 100 > End Function > > 2. --- type mismatch error--- > y = t.testF2("one", "two") > MsgBox "y= " + y > > Help please! I wasted days on this already.... from <g> You're passing 2 strings to the MsgBox function. It expects one string. The second param for the MsgBox method tells it which buttons/icons to show. '==== Private Sub Command1_Click() Call MsgBox("one", "two") 'Same error as you get End Sub '==== To show both params in one box, use: MsgBox String1 & vbCrLf & String2 -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Thank you SO much -- this REALLY saved me - I was beginning to wonder
if I should think of alteranate ways, like concatenating all parameters after converting all to the same type, and then splitting them inside the function to extract the separate ones. Thank you again!!! "Sue" <sea_***@hotmail.com> wrote in message Ken pointed out the reason for the error but you should be aware that x isnews:1142961084.801406.260040@g10g2000cwb.googlegroups.com > 1. --no error---- > Dim x, y As Integer being declared as a Variant in the above statement. You need to specify the type on all variables as in: Dim x As Integer, y As Integer -- Reply to the group so all can participate VB.Net: "Fool me once..."
Other interesting topics
Any known problems running VB6 application with Intel Centrino Duo
Windows or VB problem - Please help test for empty array? MMTimer, DirectSound, and For..Next VBnet 2005? vb6 and iso 8601 date format Access table grid component. Running external program from access VB6 DataGrid Help with cannon game |
|||||||||||||||||||||||