Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CALLBYNAME examples?

Posted on 1999-07-06
6
Medium Priority
?
618 Views
Last Modified: 2008-03-17
I need some examples of how you might use CallByName to for instance setup a variable to execute a variety of procedures and pass them different values based on what a user decides to make more reusable code.  Anyone want to try this in VB6?
0
Comment
Question by:Advanced_Tech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Inteqam
ID: 1522384
0
 

Author Comment

by:Advanced_Tech
ID: 1522385
I'd rather not get hate emails from future people who spend points to read your answer redirecting them to another answer.  Paste the answer here or dont submit an answer.  Obviously if you know thats the answer you have been there and paid the pointsd already so why make others also waste points to get to the same text?
0
 

Author Comment

by:Advanced_Tech
ID: 1522386
This gets even better the Answer you refer me to refers everyone to yet another one!  

http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10126230 

I love this!  Anyone else enjoying this as much as I am?

EE Staff needs to make posting redirections policy as officially unacceptable I think!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Inteqam
ID: 1522387
mmmmmmmmmm...........

well ,

take or leave it

i am trying to help , i am not get to be a millionare from your Q.

0
 

Author Comment

by:Advanced_Tech
ID: 1522388
True!  I doubt Expert Points will threaten to become the currency of choice for any major economies in the immediate future.  

Still any QUESTION asking for examples (ie sample code) should not simply result in redirection to another similar question which then again redirects us to yet another question.  Thats ludicrous and sets a precedent for the eventual uselessness of this entire system.  

EE Admins please delete this question as it appears nobody has any interest in trying to actually work with exploring this new VB function with us.
0
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1522389
1. Start a new Standard EXE project in Visual Basic. Form1 is created by

   default.

2. Add a Class Module (Class1) to the project.
3. Add the following code to the Class Module:


      Option Explicit
      Private MyPropValue As Integer

      Public Function Multiply(x As Integer, y As Integer) As Integer
         Multiply = x * y
      End Function

      Public Property Get MyProperty() As Variant
         MyProperty = MyPropValue
      End Property

      Public Property Let MyProperty(ByVal vNewValue As Variant)
         MyPropValue = vNewValue
      End Property

4. Add the following code to the Form Module (Form1):

      Option Explicit

      Private Sub Form_Click()
         Dim myclass As New Class1
         Dim sum As Integer
         Dim prop As Integer

         ' Example of calling a method with CallByName
         ' equivalent to -- sum = myclass.Multiply(12, 12)
         sum = CallByName(myclass, "Multiply", VbMethod, 12, 12)
         MsgBox sum

         ' Example of a property let with CallByName
         ' equivalent to -- myclass.MyProperty = 5
         CallByName myclass, "MyProperty", VbLet, 5

         ' Example of a property get with CallByName
         ' equivalent to -- prop = myclass.MyProperty
         prop = CallByName(myclass, "MyProperty", VbGet)
         MsgBox prop
      End Sub

5. Run the Project and click on Form1. A message box displaying the number
   144 and a message box displaying the number 5 are shown in succession.

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question