473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

calling .NET from VBA: one parameter only in a method?

Hello,

I'm seeing strange behavior experimenting with calling .NET. If I
create a project in .NET 2k3 and select 'interop assembly' it will
create the CCW for me, correct?

I created a class library with this class in it:
Public Class TestCCW
Public Sub Stream(ByVal filename As String)
MsgBox("filename is '" & filename & "'")
End Sub
Public Sub Stream2(ByVal filename As String, ByVal tmp As
String)
MsgBox("filename is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
Public Sub Stream3(ByRef filename As String)
MsgBox("filename is '" & filename & "' ")
End Sub
Public Sub Stream4(ByRef filename As String, ByRef tmp As
String)
MsgBox("filename is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
End Class

I build it successfully, and in Access 2k2 I make the following VBA
calls (tied to a button click):
Private Sub Command1_Click()
Dim tmp As XSDLib3.DaoSdr
Set tmp = New XSDLib3.DaoSdr
Dim rs As DAO.Recordset
Set rs = Me.Recordset
tmp.Stream ("foo")
' Compile error: Syntax error
'tmp.Stream2("stream2","bar")
tmp.Stream3 ("stream3")
' Compile error: Syntax error
'tmp.Stream4("stream4","bar")
Set tmp = Nothing
End Sub

I thought at first it might be a ByRef vs. ByVal problem, hence Stream
vs. Stream3 (which work succesffully). But that wasn't the case

Can anybody advise me as to why stream2 and stream4 fail with compile
errors?

Thanks
Nov 22 '05 #1
1 1768
On 30 Oct 2004 14:13:52 -0700, Bobby wrote:
Hello,

I'm seeing strange behavior experimenting with calling .NET. If I
create a project in .NET 2k3 and select 'interop assembly' it will
create the CCW for me, correct?

I created a class library with this class in it:
Public Class TestCCW
Public Sub Stream(ByVal filename As String)
MsgBox("filename is '" & filename & "'")
End Sub
Public Sub Stream2(ByVal filename As String, ByVal tmp As
String)
MsgBox("filename is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
Public Sub Stream3(ByRef filename As String)
MsgBox("filename is '" & filename & "' ")
End Sub
Public Sub Stream4(ByRef filename As String, ByRef tmp As
String)
MsgBox("filename is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
End Class

I build it successfully, and in Access 2k2 I make the following VBA
calls (tied to a button click):
Private Sub Command1_Click()
Dim tmp As XSDLib3.DaoSdr
Set tmp = New XSDLib3.DaoSdr
Dim rs As DAO.Recordset
Set rs = Me.Recordset
tmp.Stream ("foo")
' Compile error: Syntax error
'tmp.Stream2("stream2","bar")
tmp.Stream3 ("stream3")
' Compile error: Syntax error
'tmp.Stream4("stream4","bar")
Set tmp = Nothing
End Sub

I thought at first it might be a ByRef vs. ByVal problem, hence Stream
vs. Stream3 (which work succesffully). But that wasn't the case

Can anybody advise me as to why stream2 and stream4 fail with compile
errors?

Thanks


This is a longshot, but since Stream, Stream2, Stream3 and Stream4 are
subs, you need to call them without using parentheses:

tmp.Stream "foo"
tmp.Stream2 "stream2", "bar"
tmp.Stream3 "stream3"
tmp.Stream4 "stream4", "bar"

Not sure if this is the problem, but it's worth checking.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Murat Tasan | last post by:
i have a quick question... is there a way to obtain the reference to the object which called the currently executing method? here is the scenario, i have a class and a field which i would like to...
2
by: Alexander Straschil | last post by:
Hello! I'm fooling around with a class wich can map cgi-parameters to function named parameter. I have a dic like dic = { 'action': 'myfunc', 'x': 1, 'y': 2,
0
by: developer | last post by:
Hi All, I’m currently doing some POC testing for a new client for one of their existing applications, with the hopes of being able to migrate a lot of their existing code embedded in Excel VBA to...
1
by: Bobby | last post by:
Hello, I'm seeing strange behavior experimenting with calling .NET. If I create a project in .NET 2k3 and select 'interop assembly' it will create the CCW for me, correct? I created a class...
6
by: Clément Collin | last post by:
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .......
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
5
by: Erik | last post by:
I'm using an ActiveX control to display a Gantt chart in my Access 2003 application. It's all setup and programmed and displays nicely. The control supports printing, but its documentation is...
8
by: hbean | last post by:
Hi - I'm trying to run a query as part of a VBA procedure, and what I want it to do is to grab the value for a parameter (the current month) from another part of the procedure. I clearly am...
6
by: ranin02 | last post by:
Hi, I have a COM method that is called from VBA. This COM method in turn calls CoCreateInstance on a class that is a .NET class with a COM wrapper around it. This all works fine. However,...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.