Normally when you create an event handler say for a windows forms application event there are two parameters - normally the first is sender as object and the second is some kind of EventArgs.
Some examples are
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,Button2Click
End Sub
The sender is actually identifying which control is initiating this call. As you can hook up the same event to multiple controls or events. So in the 2nd example you could use sender to determine where button1 or button2 was the control which caused the event method to be executed.
Class Form1
Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles TextBox1.Leave, TextBox2.Leave
Dim someboxtext As String = CStr((CallByName(sender, "Text", CallType.Get)))
MsgBox(
CStr((CallByName(sender, "Name", CallType.Get))) & someboxtext)
End Sub
i am trying to take the texbox name and then send it to another procedure without typing the name of the textbox from the leave event of the textbox
How about a sample of what you are trying to do You question is not very clear. If you are trying to assign something from a textbox,like the text in the textbox, to another procedure, you will have to reference the Textbox1.Text in the other procedure:
I do a use the textbox name with out typing it
Steve Strong
im getting this error how do i get round it
Error 1 Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'.
Lawr3nc3
is where the error is occuring
UsingBytes
i want to remove S631 from the code
Private
Sub S631_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles S631.Leave Dim nu As String Dim na As Stringna = "S631"(the name of the textbox)
nu = S631.Text
Module1.AdSt(nu, na)
End Subvinclaro001
Dim nu As String
Dim textBox As TextBox = DirectCast(sender, TextBox).NameDim na As String
na = textBox.Name
nu = textBox.Text
Module1.AdSt(nu, na)Andrej
Christer Claesson
Normally when you create an event handler say for a windows forms application event there are two parameters - normally the first is sender as object and the second is some kind of EventArgs.
Some examples are
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,Button2Click
End Sub
The sender is actually identifying which control is initiating this call. As you can hook up the same event to multiple controls or events. So in the 2nd example you could use sender to determine where button1 or button2 was the control which caused the event method to be executed.
Kurt Berglund - MSFT
Thanks for the help had to textbox = DirectCast(sender, TextBox) after the dim to get it work
Private
Sub S631_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles S631.Leave Dim nu As String Dim na As String Dim textbox As TextBoxtextbox =
DirectCast(sender, TextBox)na = textbox.Name
nu = textbox.Text
Module1.AdSt(nu, na)
end sub
Aurels
You want to ensure that you are setting the text property
Textbox1.text = "sdsdsdsd"
not
Textbox1= "sdsdsdsd"
Cesar Francisco
Public
Class Form1 Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles TextBox1.Leave, TextBox2.Leave Dim someboxtext As String = CStr((CallByName(sender, "Text", CallType.Get)))MsgBox(
CStr((CallByName(sender, "Name", CallType.Get))) & someboxtext) End SubEnd
ClassKevin Rodgers
search and deploy
This will fail as your trying to assign a string to a textbox, breaking it down into two steps should help.
Dim textBox As TextBox = DirectCast(sender, TextBox)textBox.Name = sender.name
Tryin2Bgood
I'mSorry, had a typo when pasting the code
- I forgot to remove .Name from the DirectCast line. Glad you figured it out yourself.
Andrej
Hyde
MyotherValue = Textbox1.Text
Is that what you are wanting to do
james
aka:Trucker