Compile Error - Expected Function or variable

M

mail_garp

Hi,

I am starting with VBA and try at the moment to call a web service via
following code:
-------------------
Private Sub CommandButton1_Click()
Dim ws_call As New clsws_ZZXMLUPLOADService
Set ws_call = New clsws_ZZXMLUPLOADService

Dim output(0) As struct_ZOXDBW0121
Set output(0) = New struct_ZOXDBW0121
output(0).BIC_Z9S_MATNM = "Product 1"
output(0).QUANTITY = "1"
output(0).UNIT = "EA"

Dim ds As String
ds = "6AZZXMLUPLOAD_IS"

Dim result As MSXML2.IXMLDOMNodeList
result = ws_call.wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC(output, ds)

End Sub
--------------------
The class of the web_service is created and there also a sub with that
name exists (in the above code I inserted it also with value help -->
it appeared after I types ws_call.

Sub Code
--------------
Public Sub wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC(ByRef ar_DATA As Variant,
ByVal str_DATASOURCE As String)

'Error Trap
On Error GoTo wsm_BI0_QI6AZZXMLUPLOAD_IS_RFCTrap

sc_ZZXMLUPLOADService.BI0_QI6AZZXMLUPLOAD_IS_RFC ar_DATA,
str_DATASOURCE

Exit Sub
--------------


Any ideas why I do get the compile error?

Many thanks in advance for all replies.
 
S

Stefan Hoffmann

hi Garp,

Private Sub CommandButton1_Click()
Dim ws_call As New clsws_ZZXMLUPLOADService
Set ws_call = New clsws_ZZXMLUPLOADService
The declaration "As New" creates the class automatically. It is not
necessary to create it a second time.

Despite that, don't use "As New" as it has some bad kind of behavior:
Each object declared "As New" is automatically created when accessed.

Dim a As New clsws_ZZXMLUPLOADService

Set a = Nothing

'assume your class has a name property
MsgBox a.Name

The usage for the message box recreates a new object.
Dim output(0) As struct_ZOXDBW0121
Set output(0) = New struct_ZOXDBW0121
If it is a structure, you can't create it. Just use it.
The class of the web_service is created and there also a sub with that
name exists (in the above code I inserted it also with value help -->
it appeared after I types ws_call.
I don't get your point.
Any ideas why I do get the compile error?
Where does what error occure?


mfG
--> stefan <--
 
M

mail_garp

Hi Stefan,

thanks for the hints.

The compiler error occurs for the code line result =
ws_call.wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC(output, ds)
Error: Compile Error - Expected Function or variable

As far as I understood it it appears when I try to call a function/sub
but don't use the correct name or if the assignment is Sub = xy is
done. But my assignment should work as I will get an return value.


Thanks,
Axel
 
S

Stefan Hoffmann

hi Garp,

The compiler error occurs for the code line result =
ws_call.wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC(output, ds)
Error: Compile Error - Expected Function or variable
Your called method wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC is a sub. From the
naming of the parameters, i assume it must be:

ws_call.wsm_BI0_QI6AZZXMLUPLOAD_IS_RFC result, ds
'do with the variable result what you like.


mfG
--> stefan <--
 
Top