Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2005, 01:08 PM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type Casting in VBA


I have a project wherein I need to cast an object as a Control. Unfortunately, I can't seem to get CType to work in VBA. Does VBA support the CType keyword, and if does, what specific references need to be set the project.

Thanks in Advance

 
Old February 14th, 2005, 08:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Unfortunately VBA doesn't support type casting. It isn't a fully object-oriented language. You can neither inherit classes in your own custom class definitions, nor can you get your objects to behave polymorphically (e.g., cast them as an instance of their base class). VB6 doesn't support inheritance/polymorphism either, but VB.NET and C# do.

HTH,

Bob

 
Old March 5th, 2006, 04:49 PM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what is VB6??


upama
 
Old March 5th, 2006, 05:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

VB6 was Microsoft’s primary, high-level, Windows application development language and platform. About 3 million developers in the U.S. alone use it. Microsoft recently decided to discontinue development and support for it, however, and VB.NET (which is completely unlike VB6, ‘cept for the “V” and the “B”) and C# are Microsoft’s current, primary, high-level, Windows application development languages.

Bob

 
Old March 5th, 2006, 08:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

 
Quote:
quote:VB6 doesn't support inheritance/polymorphism either, but VB.NET and C# do.


Should have said VB6 doesn't support implementation inheritance (which is why it doesn't support polymorphism either). It does, however, support interface inheritance (but by definition interfaces define empty members - methods, properties, etc. - and don't contain any member implementations). NET does all this stuff.

Bob

 
Old April 13th, 2012, 01:43 PM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type Casting in VBA is Partially Supported

If you want to find a control in the current sheet in excel for example named "MyLabel" and set it's image property to a file located on "C:\Images\Image1.jpg"
you can yuse the following code

==================================
Dim lbl As MSForms.Label
Set lbl = Me.OLEObjects("MyLabel").Object
lbl.Picture = LoadPicture("C:\Images\Image1.jpg")
===================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting pfrigo BOOK: Professional .NET 2.0 Generics 3 November 19th, 2007 04:49 PM
Casting - Can you help koco C# 1 September 24th, 2007 08:41 AM
Type Casting in VBA miriv365 VB.NET 0 February 14th, 2005 01:07 PM
casting textbox to sqlserver number data type yoord BOOK: Beginning ASP.NET 1.0 1 October 17th, 2004 06:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.