473,779 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("filenam e is '" & filename & "'")
End Sub
Public Sub Stream2(ByVal filename As String, ByVal tmp As
String)
MsgBox("filenam e is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
Public Sub Stream3(ByRef filename As String)
MsgBox("filenam e is '" & filename & "' ")
End Sub
Public Sub Stream4(ByRef filename As String, ByRef tmp As
String)
MsgBox("filenam e 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("s tream2","bar")
tmp.Stream3 ("stream3")
' Compile error: Syntax error
'tmp.Stream4("s tream4","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 1799
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("filenam e is '" & filename & "'")
End Sub
Public Sub Stream2(ByVal filename As String, ByVal tmp As
String)
MsgBox("filenam e is '" & filename & "' tmp is '" & tmp &
"'")
End Sub
Public Sub Stream3(ByRef filename As String)
MsgBox("filenam e is '" & filename & "' ")
End Sub
Public Sub Stream4(ByRef filename As String, ByRef tmp As
String)
MsgBox("filenam e 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("s tream2","bar")
tmp.Stream3 ("stream3")
' Compile error: Syntax error
'tmp.Stream4("s tream4","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_lunch meat_[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
9634
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 populate with a reference to the object that constructed this current object. i would attempt to accomplish this by setting the appropriate field from within the constructor... i figured it might be obtainable from the stack trace, but that...
2
1549
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
1689
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 .net C# classes. At the moment I am working at the simplest level (not getting in to Add-ins just yet) from a COM point of view. Up until now I have had no problems translating some of the tamer functions that they currently have in VBA, however...
1
318
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 library with this class in it: Public Class TestCCW Public Sub Stream(ByVal filename As String) MsgBox("filename is '" & filename & "'")
6
6725
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 : .... Var RecordNb : integer ; .... {Command : function of Access}
7
4987
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 Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
5
5264
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 not very good. A VB example is supplied in the documentation, but it does not work in VBA. The VB example goes: Object.PrintToHdc Printer.hdc, 100, 100, 5, 5, 200....etc (multiple layout
8
20767
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 missing something, however. Here's what I have: Dim db As Database Dim rs As Recordset Dim rs2 As Recordset
6
3626
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, when I kick off that VBA routine from a .NET class within an assembly, I get a class not registered error. When CoCreateInstance is called on that COM visible .Net class a second time, then there is a security violation. To try to make it clearer:
7
2688
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 name based on the name of the VB6 application. A second choice would be a file name based on the # COM interface assembly. I have tried calling Assembly.GetCallingAssembly() but this fails when I use the VB6 client. Is there a way to get this...
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.