473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to return just the Text value from "sender"

Rob
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...

Is there a way to return only the Text value (i.e., some additional property
designate) ?
May 16 '07 #1
4 15603
On May 16, 7:31 am, "Rob" <r...@yahoo.comwrote:
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...

Is there a way to return only the Text value (i.e., some additional property
designate) ?
If you know that it is a button, you can use this line:

DirectCast(sender, Button).Text

Chris

May 16 '07 #2
Rob,

By convention, sender usually represents the object that has raised an event.

If you know the type of the object you can convert it to its actual type and
then reference any of the object's properties, etc.

For example, if you know that sender is a button:

Dim btn As Button = CType (sender, Button)

Now you have access to the button's properties and methods in the btn
reference.

Kerry Moorman
"Rob" wrote:
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...

Is there a way to return only the Text value (i.e., some additional property
designate) ?
May 16 '07 #3
Yes. In order to get the Text property from the sender object, you need to
cast it to a button:

MsgBox(CType(sender, Button).Text)
"Rob" wrote:
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...

Is there a way to return only the Text value (i.e., some additional property
designate) ?
May 16 '07 #4
On May 16, 9:00 am, Chris Dunaway <dunaw...@gmail.comwrote:
On May 16, 7:31 am, "Rob" <r...@yahoo.comwrote:
I see that MsgBox(sender.ToString()) will return a string that includes the
Text value of a button...
Is there a way to return only the Text value (i.e., some additional property
designate) ?

If you know that it is a button, you can use this line:

DirectCast(sender, Button).Text

Chris
If you know that it is a button, you can use this line:
Or really you could cast sender into a Control to cover a wider range
of controls

DirectCast(sender, Control).Text

Thanks,

Seth Rowe

May 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
6
by: Jax | last post by:
Custom control problem. I'm modding a textbox so that it will always have a "%" sign at the end of it. I have overrided the Text property to account for the "%" value within the textbox and have...
0
by: Sin | last post by:
Hello, I'm currently toying around with using a VB.NET interface in a VC.NET program and I've come across somewhat of a problem. I found a workaround but I figure I must be a bit off cause it...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Goethals Frederik | last post by:
hi, I have a little problem with the function "Page.GetPostBackClientHyperlink". First some description of my page: It is a simple testpage for testing "selecting a row af the datagrid by...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
3
by: Alan LeHun | last post by:
I want to attach a context menu to multiple textboxes but I don't know how the extract the name of the textbox that is the subject of the event. I can't seem to do anything with "sender as...
1
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
4
by: Spectre1337 | last post by:
Hello, to my understanding the ASP.NET process works as follows: 1) Page_Init(): At this moment the user should allocate his controls, set their IDs and connect them to the page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.