Hi all,
I am facing one problem with callbyName. I am facing one problem, instead
of describing this I am pasting this code. I wanted to know is there any
other way to avoid this error and make generalized functions.
Please see the code.
Regards,
Kishor
Module Module1
Sub Main()
Dim pp1 As String = "Kishor"
Dim pp2 As String = "Ashish"
Dim pp3 As String = "Darshan"
Dim ppx1() As String = {"Kishor", "Rajeev", "Sonia"}
Dim ppx2() As String = {"Varsa", "Jassi", "Dahi bada"}
Dim ppx3() As String = {"MPK", "QSQT", "HAHK", "K3g", "PYTKK"}
Dim oc As New mycls()
'CallByName(oc, "TwoSingleParam ", CallType.Method , pp1, pp2)
'CallByName(oc, "TwoArrayParam" , CallType.Method , ppx1, ppx2)
'CallByName(oc, "OneSingleParam ", CallType.Method , pp1)
CallByName(oc, "OneArrayParam" , CallType.Method , ppx2)
'CallByName(oc, "ThreeArrayPara m", CallType.Method , ppx1, ppx2, ppx3)
End Sub
Public Class mycls
Public Sub TwoSingleParam( ByVal p1 As String, ByVal p2 As String)
MsgBox(p1 & ".......... ." & p2)
End Sub
Public Sub TwoArrayParam(B yVal p1() As String, ByVal p2() As String)
Dim i As Integer
For i = 0 To UBound(p1)
MsgBox(p1(i) & " " & p2(i))
Next
End Sub
Public Sub OneSingleParam( ByVal p1 As String)
MsgBox(p1)
End Sub
Public Sub OneArrayParam(B yRef p1() As String)
Dim i As Integer
For i = 0 To UBound(p1)
MsgBox(p1(i))
Next
End Sub
Public Sub OneArrayParamxx (ByRef p1 As String, ByRef p2 As String,
ByRef p3 As String)
MsgBox(p1 & "" & p2 & "" & p3)
End Sub
Public Sub ThreeArrayParam (ByVal p1() As String, ByVal p2() As
String, ByVal p3() As String)
Dim i As Integer
MsgBox("chal gaya 1a")
For i = 0 To UBound(p1)
MsgBox(p1(i))
Next
For i = 0 To UBound(p2)
MsgBox(p2(i))
Next
For i = 0 To UBound(p3)
MsgBox(p3(i))
Next
End Sub
End Class
End Module 1 2394
Hi Kishor,
I presume the commented out CallByNames give you errors.
The fourth parameter of CallByName is
ByVal ParamArrayArgs( ) As Object
This means that your parameters must be bundled up together in an Object
array.
CallByName (oc, "WhateverParam" , CallType.Method , _
New Object() { --the parameters go here-- })
Regards,
Fergus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Olcott |
last post by:
www.halting-problem.com
|
by: Edlueze |
last post by:
I use the CallByName function quite regularly, but the sub routines
that I have always called have been located within the form code. The
call I use looks something like this:
Dim CallObjectForm As Form
Set CallObjectForm = Forms("My Form")
CallByName CallObjectForm, "My_Form_SubRoutineCall", VbMethod
I now want to call code that is located within a standard module and I
am not having any luck. I'm trying to use the following code:
|
by: Jon Davis |
last post by:
If I have a class with a virtual method, and a child class that overrides
the virtual method, and then I create an instance of the child class AS A
base class...
BaseClass bc = new ChildClass();
.... and then call the virtual method, why is it that the base class's method
is called instead of the overridden method? How do I fix this if I don't
know at runtime what the child class is? I'm using
Activator.CreateInstance() to load the...
|
by: Jelle van Baardewijk |
last post by:
Does anybody know if there's way to do this in C#?
Jelle van Baardewijk
|
by: MFRASER |
last post by:
Is there any CallbyName function inside of C#.
I need to shift my items in a collection
Psuedo code
aItem has hours 1-24 and I need to be able to shift the hours.
foreach(MapItem aItem in aCol.Items)
{
| |
by: Rob R. Ainscough |
last post by:
I use a generic Processing form (modal) where I pass it an object and method
name and parameters if needed and then use CallbyName to execute the passed
in method. What this does for me is lock out user input on the parent form
as the Processing form has no input controls until all processing is
complete.
I was curious if CallByName is a good way to perform this operation?
|
by: Tim |
last post by:
If I use CallByName, and the function that is called contains runtime
errors, I don't get the code to pause and debug at the point of the
error, rather at the callbyname line.
This makes debugging really very tricky.
Am I doing something wrong?
Is there an obvious fix to enable the pause on error to pause at the
right place?
|
by: Timberwoof |
last post by:
For i = 1 To 3
CallByName(Form1.Controls("ComboBox" & i), "items.add", Type.Set, "1st item")
CallByName(Form1.Controls("ComboBox" & i), "items.add", Type.Set, "2nd item")
CallByName(Form1.Controls("ComboBox" & i), "items.add", Type.Set, "3rd item")
next
Is there a way I can populate these 3 combo boxes using the CallByName feature. My form has 3 combo boxes named ComboBox1, ComboBox2, ComboBox3.
I would really Prreeeeeeciate your...
|
by: penguinie |
last post by:
First add to referance Microsoft.VisualBasic
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
namespace CallByNameConsole
{
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |