Late Binding and the compact framework

davidh

Active member
Joined
Jul 8, 2003
Messages
31
Location
UK
I am trying to make a calculator-style keypad for a form in an app running on the CF. Obviously I dont really want a different routine for each button if I can help it as each one does the same thing. So I tried

Private Sub Number_Handler(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
btnZero.Click, _
btnOne.Click, _
btnTwo.Click, _
btnThree.Click, _
btnFour.Click, _
btnFive.Click, _
btnSix.Click, _
btnSeven.Click, _
btnEight.Click, _
btnNine.Click
Handles clicking the buttons for all number buttons

If txtNumber.Text = "0" Then
Text is still zero so just change the text to the number on the button
txtNumber.Text = sender.Text
Else
txtNumber.Text &= sender.Text
End If

End Sub

but the CF doesnt support late binding so I cant use sender.Text as its an object without a Text property.

Is there another way to do this or have I just got to have a routine for each button?

Thanks in advance
 
You have to cast it, just like you should be doing with the regular framework (put option strict on).

Code:
DirectCast(sender, TextBox).Text = "blah"
 
Back
Top