Late Binding Problem - Need Help

S

Siv

Hi,
I have this block of old code:

Private Sub txtBoxes_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) _
Handles txtQL12.DragDrop, txtQL11.DragDrop, txtQL10.DragDrop,
txtQL09.DragDrop, _
txtQL08.DragDrop, txtQL07.DragDrop, txtQL06.DragDrop,
txtQL05.DragDrop, _
txtQL04.DragDrop, txtQL03.DragDrop, txtQL02.DragDrop,
txtQL01.DragDrop, _
txtV01.DragDrop, txtV02.DragDrop, txtV03.DragDrop, txtV04.DragDrop,
_
txtV05.DragDrop, txtV06.DragDrop, txtV07.DragDrop, txtV08.DragDrop,
_
txtV09.DragDrop, txtV10.DragDrop, txtV11.DragDrop, txtV12.DragDrop,
_
txtV13.DragDrop, txtV14.DragDrop, txtV15.DragDrop, txtV16.DragDrop,
_
txtV17.DragDrop, txtV18.DragDrop, txtV19.DragDrop, txtV20.DragDrop,
_
txtQuoteValidFrom.DragDrop

sender.Text += e.Data.GetData(DataFormats.Text).ToString

End Sub

I am converting my application so that it runs with Option Strict on and the
compiler complains about the late binding being used here (sender.text), can
anyone recommend a neat way of handling this without having to write an
individual event procedure for each of these text boxes that will avoid the
late binding issue. I have pondered it for a while and can't think of a way
of doing it that will not hit the same late binding issue.

Thanks for your help.

Siv
Martley, Near Worcester, UK.
 
A

Armin Zingler

Siv said:
sender.Text += e.Data.GetData(DataFormats.Text).ToString

End Sub

I am converting my application so that it runs with Option Strict on
and the compiler complains about the late binding being used here
(sender.text), can anyone recommend a neat way of handling this
without having to write an individual event procedure for each of
these text boxes that will avoid the late binding issue. I have
pondered it for a while and can't think of a way of doing it that
will not hit the same late binding issue.

If it's all textboxes:

directcast(sender, textbox).Text += ...


Armin
 
S

Siv

Armin,
Yes they are. I was unaware of that function. Brilliant, I'll try it and see
if it works. If it does it will save a heck of a lot of code.
Thanks for your help.

Siv
 
S

Siv

Armin,
Yes, the compiler seems happy now. I still have a lot more code to convert
before I can run the app, but will post back here with the results when I
do.

Thanks again. Something I have learned today!

Siv
 
S

Siv

Armin,
I have now completed the conversion and the directcast function hasn't
caused any problems.
Many thanks.

Siv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top