Home All Groups Group Topic Archive Search About

Need equivalant code in VB.Net 2005 ?

Author
1 Feb 2006 8:53 AM
Luqman
In VB-6, I have put my field names in DataField Property of Textbox for Tag
Purpose.

In code, I use it as under:-

for each control in me.controls
if typeof control is textbox then
myrecordset.fields(control.datafield).value=control.text
endif
next

How can I use above code or similar in Vb.Net ?

Best Regards,

Luqman

Author
1 Feb 2006 11:47 AM
CMM
My first guess is to inherit from the textbox and add your "datafield" to
it. Add a textbox to your form. Go into generated code (this differs between
2002 and 2005) and change "...As Textbox" to "...As MyTextBox." Voila.

Similar to your predicament, I missed the Tag property in Menus when I
started using VB.NET... luckily its easy to extend the functionality of any
control in .NET.

Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl...
> In VB-6, I have put my field names in DataField Property of Textbox for
> Tag
> Purpose.
>
> In code, I use it as under:-
>
> for each control in me.controls
> if typeof control is textbox then
> myrecordset.fields(control.datafield).value=control.text
> endif
> next
>
> How can I use above code or similar in Vb.Net ?
>
> Best Regards,
>
> Luqman
>
>
>
>
Author
1 Feb 2006 12:08 PM
Ken Tucker [MVP]
Hi,

        Try using the textbox's tag instead

Ken
---------------
Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl...
> In VB-6, I have put my field names in DataField Property of Textbox for
> Tag
> Purpose.
>
> In code, I use it as under:-
>
> for each control in me.controls
> if typeof control is textbox then
> myrecordset.fields(control.datafield).value=control.text
> endif
> next
>
> How can I use above code or similar in Vb.Net ?
>
> Best Regards,
>
> Luqman
>
>
>
>
Author
1 Feb 2006 12:09 PM
Al Reid
If you are not using the Tag property for anything else, use it to hold the field name.  Also, as already mentioned, it's east to
extend the controls to add field name and table name, etc.

--
Al Reid


Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl...
> In VB-6, I have put my field names in DataField Property of Textbox for Tag
> Purpose.
>
> In code, I use it as under:-
>
> for each control in me.controls
> if typeof control is textbox then
> myrecordset.fields(control.datafield).value=control.text
> endif
> next
>
> How can I use above code or similar in Vb.Net ?
>
> Best Regards,
>
> Luqman
>
>
>
>
Author
1 Feb 2006 12:27 PM
Cor Ligthert [MVP]
LuqMan

Have a look at databinding, that makes live a lot easier.

http://www.vb-tips.com/default.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8

I hope this helps,

Cor