Regarding the dropdetect function, defined as follows:
Sub dropdetect(Drop Frm 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)DropCt rl
Is there any analogous code in VBA? Thanks.
-Vincent 4 14524
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**********@v erizon.net> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . Regarding the dropdetect function, defined as follows:
Sub dropdetect(Drop Frm 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)DropCt rl
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(Drop Frm As Form, _
DropCtrl As Access.Textbox, _
Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)
(david)
"Vincent" <an**********@v erizon.net> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . Regarding the dropdetect function, defined as follows:
Sub dropdetect(Drop Frm 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)DropCt rl
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**********@v erizon.net> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . Regarding the dropdetect function, defined as follows:
Sub dropdetect(Drop Frm 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)DropCt rl
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*********@Se eSig.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**********@v erizon.net> wrote in message news:11******** **************@ i39g2000cwa.goo glegroups.com.. . Regarding the dropdetect function, defined as follows:
Sub dropdetect(Drop Frm 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)DropCt rl
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, and load a list of Objects
(in this case, TTSProject objects). the problem i see when i try to run it,
is the following:
name :
Traceback (most recent call last):
File "ProjectParser.py", line 63, in ?
|
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
command methods. This is exactly what the Microsoft Data Access Application
Block assembly does but I coded my own simple, custom class.
I have a method named "ExecuteAggregate" that takes in a sql string like
|
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 along. It says it's an invalid cast.
However, if I use the Convert.ToInt32() method (for example) things will
work. At least, that's how it appears to me.
Could someone explain when to use old-style parenthesized casts vs. the
Convert() methods?
|
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") + 1
Why?
Thanks
Dee.
|
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 absolutely no added functionality to it.
| |
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 the
validation. But I get and error of "The type or namespace name 't' could not
be found (are you missing a using directive or and assembly reference?) on
the "is" operator and the casting operation.
An example of the method follows. The...
|
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
System.CodeDom.CodeCastExpression)
__problem typecast #1
Desc:i do needed checks but data/commands in XML is dynamic and i don't
wanna fix C# code again and again...
Sample:foreach (object some in somearray)
(some.GetType())some.someaction();
|
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
not looking for a work-around).
Again, I am appreciative of the feedback. I will note, that even though I
can use Interfaces, the calling application and the dynamically loaded
assembly both need compile-time refrences to the assembly that...
|
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...
|
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: 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: 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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |