A1VBCode Forums

Use sub


http://www.a1vbcode.com/vbforums/Topic28775.aspx

By samuvk - 1/28/2010

I'm using Visual Basic in Excel 2003.

I have a Sub definied as follow:

Public Sub Conect(ByVal hServer As Long, ByVal hpool As Long, ByVal vServerName As Long, ByVal vUserName As Long, ByVal vPassword As Long, hUser As Long)

  BODY

End Sub

The thing is when I try to call the Sub I'm doing as follow:

Sub Conect(hServer, hpool, vServerName, vUserName , vPassword , hUser Wink

When I call the Sub I get the next error message:

Compile error:

Expected:=

Could anyone help me to understand why is this happening and how can I fix it?

The thing is that when I use only one variable I don't have any problem

By Joey - 1/30/2010

When you're calling the sub either get rid of the parentheses like this,

Conect hServer, hpool, vServerName, vUserName , vPassword , hUser 

or, leave the parentheses and use the CALL keyword, like this,

Call Conect(hServer, hpool, vServerName, vUserName , vPassword , hUser)

You were getting the error because it was expecting a return value from a function to be assigned to a variable such as,

myConString = Conect(hServer, hpool, vServerName, vUserName , vPassword , hUser)