Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Classic Visual Basic (VB 6 or earlier) » VBA(Excel, Word, etc...) » Use sub


Use subExpand / Collapse
Author
Message
Posted 1/28/2010 3:13:10 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/22/2010 9:15:29 AM
Posts: 7, Visits: 16
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 

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

Post #28775
Posted 1/30/2010 10:58:07 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 3/17/2011 8:55:21 PM
Posts: 57, Visits: 31
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)

Post #28780
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 10:51pm