developer2012
asked on
TextBox control can not be converted to value system.windows.controls.button
Hi everyone,
I have the below logic for increment and decrement button in vb.net.
And I am calling the functions on the event handler something like that:
On the runtime it gives me an exception system.windows.textbox can not be converted to system.windows.button.
Any idea how to resolve it Please?
Thanks
I have the below logic for increment and decrement button in vb.net.
Private Sub IncrementBox(ByVal sender As TextBox)
Dim value As Integer
If Integer.TryParse(sender.Text, value) Then
sender.Text = (value + 1).ToString()
End If
End Sub
And I am calling the functions on the event handler something like that:
Private Sub btnDown_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnDown.Click
IncrementBox((DirectCast(sender, TextBox)))
End Sub
On the runtime it gives me an exception system.windows.textbox can not be converted to system.windows.button.
Any idea how to resolve it Please?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks =))
Open in new window
Where textboxname is substituted for a name made up of a combination of the button clicked name and a constant so you relate button to text boxButton = button1
TextBox = button1_text