Regarding the dropdetect function, defined as follows:
Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer,
Shift As Integer, X As Single, Y As Single)
Is it possible to cast the Control parameter, DropCtrl, to a TextBox
object? The underlying control is in fact a textbox which I wish to
redraw given the X and Y parameters above. In Java, you could simply
declare a TextBox reference and assign it to the Control object as
follows:
Dim myTextBox as TextBox
myTextBox = (TextBox)DropCtrl
Is there any analogous code in VBA? Thanks.
-Vincent 4 14473
Try:
Dim myTextBox as TextBox
Set myTextBox = DropCtl
Anything you can do with a TextBox object, you should also be able to do
directly with a Control object anyway, so I'm not sure why you would need to
do that.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Vincent" <an**********@verizon.net> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... Regarding the dropdetect function, defined as follows:
Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single)
Is it possible to cast the Control parameter, DropCtrl, to a TextBox object? The underlying control is in fact a textbox which I wish to redraw given the X and Y parameters above. In Java, you could simply declare a TextBox reference and assign it to the Control object as follows:
Dim myTextBox as TextBox myTextBox = (TextBox)DropCtrl
Is there any analogous code in VBA? Thanks.
-Vincent
You can only do implicit casting by assigning
the object to a variable of different type
That is, you can do implicit casting without
a cast operator:
Dim myTextBox as Access.TextBox
set myTextBox = DropCtrl
or
Sub dropdetect(DropFrm As Form, _
DropCtrl As Access.Textbox, _
Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)
(david)
"Vincent" <an**********@verizon.net> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... Regarding the dropdetect function, defined as follows:
Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single)
Is it possible to cast the Control parameter, DropCtrl, to a TextBox object? The underlying control is in fact a textbox which I wish to redraw given the X and Y parameters above. In Java, you could simply declare a TextBox reference and assign it to the Control object as follows:
Dim myTextBox as TextBox myTextBox = (TextBox)DropCtrl
Is there any analogous code in VBA? Thanks.
-Vincent
When casting you really should test that the interface is supported which
you do uing the TypeOf predicate you can then simply assign variable to
variable as follows:-
Dim myTextBox as TextBox
If TypeOf DropCtrl is textbox then
Set myTextBox = DropCtrl
' ...
Else
' Do something else because it's not a textbox
end if
--
Terry Kreft
"Vincent" <an**********@verizon.net> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... Regarding the dropdetect function, defined as follows:
Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single)
Is it possible to cast the Control parameter, DropCtrl, to a TextBox object? The underlying control is in fact a textbox which I wish to redraw given the X and Y parameters above. In Java, you could simply declare a TextBox reference and assign it to the Control object as follows:
Dim myTextBox as TextBox myTextBox = (TextBox)DropCtrl
Is there any analogous code in VBA? Thanks.
-Vincent
Very early binding which gives a performance increase (I know, I know it
won't even be noticeable but I had to give the _correct_ answer first)
Probably more important to some is that casting to the correct interface
then gives you the correct information in the context sensitive drop-downs
in the editor.
--
Terry Kreft
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au... Try: Dim myTextBox as TextBox Set myTextBox = DropCtl
Anything you can do with a TextBox object, you should also be able to do directly with a Control object anyway, so I'm not sure why you would need
to do that.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Vincent" <an**********@verizon.net> wrote in message news:11**********************@i39g2000cwa.googlegr oups.com... Regarding the dropdetect function, defined as follows:
Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single)
Is it possible to cast the Control parameter, DropCtrl, to a TextBox object? The underlying control is in fact a textbox which I wish to redraw given the X and Y parameters above. In Java, you could simply declare a TextBox reference and assign it to the Control object as follows:
Dim myTextBox as TextBox myTextBox = (TextBox)DropCtrl
Is there any analogous code in VBA? Thanks.
-Vincent
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sang park |
last post by:
Hi all - Just started learning Python this past week and had a question
about using the lists in python with objects. (code attached below).
basically, what i want to do is read an xml file,...
|
by: Jack MacRank |
last post by:
Hello,
I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro
on WinXP SP2 using IIS 5.1).
I created a seperate "data" class to house all the MySQL connection and sql...
|
by: Jim Bancroft |
last post by:
Hi everyone,
A basic one here, I think. I haven't found the pattern yet, but
sometimes when I cast a variable to another type using the "C" style cast
operator the compiler refuses to play...
|
by: dee |
last post by:
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") +...
|
by: Mike Cooper |
last post by:
There is something about inherited classes I evidently don't know...
I wrote the following class:
Class Class1
inherits System.Windows.Forms.DataGridTextBoxColumn
End Class
There is...
|
by: JimM |
last post by:
I am trying to create a method in VS 2003 that validates an object argument
is of the proper type and within a range of values.
I am trying to use a Type to define the casting and object type for...
|
by: SunnyDrake |
last post by:
HI!
I wrting some program part of it is XML config parser which contains
some commands(for flexibility of engenie).
how do i more simple(if it possible not via System.Reflection or...
|
by: Ronald Raygun |
last post by:
If I have the following class heirarchy:
class A{
protected $m_type;
function type(){return $this->m_type;}
}
class B extends A{}
class C extends B{}
|
by: Robert |
last post by:
Thanks George, I really am grateful for attempts to be helpful, but this
really doesn't answer the question in my OP.
What I am looking for is an explanation of WHY things are this way (I was...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
| |