PC Review


Reply
Thread Tools Rate Thread

Basic How To Question: Class Library or Windows Control Library

 
 
eBob.com
Guest
Posts: n/a
 
      19th Feb 2006
I have several applications which mine web sites for personal information
which they publish. They publish the info in one form, I transform the info
into Excel spreadsheets.

So all these programs pick up name, telephone number, age, sex, etc.. And
as they pick up the information they display it in text boxes. The text
boxes are display only, and the info is displayed only for debugging
purposes.

Right now I have a lot of duplicate code in these several applications.
What I'd like to do is create one something, a class library or a user
control, which eliminates all of the duplicate code. So this "something" as
I envision it will be a collection of labels and textboxes (tbxName, tbxTel,
tbxSex, etc.) and a class with corresponding fields (Name, Telephone, Sex,
etc.). The something should also contain related subroutines such as the
code which opens, writes, and closes the Excel spreadsheet.

I wasn't sure if I needed a user control or a class library, but I have
opted for the user control because I want to be able to plonk down the
collection of labels and text boxes during the design of the consuming
applications.

I am now at the point where I have a bunch of labels and text boxes defined
on my "UserControl1.vb[Design]* tab. And now I am trying to define a class
of corresponding fields. So following my "Windows Form Designer generated
code" I have ...

Public Class Person

Private mpName As String

Public Property Name() As String

Get

Return mpName

End Get

Set(ByVal Value As String)

mpName = Value

UserControl1.tbxName = Value '<<<<< this is where I have a problem

End Set

End Property

....

If it matters, note that this Person class is nested within the Public Class
UserControl1. I didn't know classes can be nested but I guess I do now.

I suspect that I am really not going about this in the right way at all.
But, if I am, then my problem is that I do not know how to specify the
controls which correspond to my fields. You'll see above that I tried
UserControl1.tbxName which I knew was wrong, but it at least conveys what I
am trying to do. I had high hopes for me.tbxName but that did not work
either.

So ... any advice or pointers you can share with me will be greatly
appreciated.

Thanks, Bob


 
Reply With Quote
 
 
 
 
Cerebrus99
Guest
Posts: n/a
 
      20th Feb 2006
Hi eBob

You could consider creating both a Class Library (which contains all your
business logic and properties) and a UserControl (which contains all UI
elements.) and then link both of them together. There is of course the
option of nesting everything within one class, but it's not very good coding
practice in my opinion, especially considering that the Reusability
requirement in your project is high.

As for the confusion about whether to use a Class Library or UserControl,

By Definition :
- A Class Library template is used to quickly create reusable classes and
components that can be shared with other projects.

- The UserControl provides an empty control that can be used to create other
controls, and gives you the ability to create controls that can be used in
multiple places within an application.

So, to summarize, the Class library should contain all the logic by which
you load data, it will have properties and methods, while your UserControl
should handle the displaying of the data in the TextBoxes.

> UserControl1.tbxName = Value '<<<<< this is where I have a problem


I fail to understand what exactly you are trying to do by this statement.
You are equating a Control (texbox) with a string value, which won't work.
I'm assuming that you want to change the text of the Textbox here.

if tbxName is the name of a TextBox, then to change it's text, just do :
tbxName.Text = MyClass.PropertyName
where MyClass is the name of your ClassLibrary and PropertyName is the name
of the relevant property.

I would recommend that you check up on some tutorials on the web or MSDN,
which will clear these concepts.

Lemme know if you need more info,

Regards,

Cerebrus.



"eBob.com" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have several applications which mine web sites for personal information
> which they publish. They publish the info in one form, I transform the

info
> into Excel spreadsheets.
>
> So all these programs pick up name, telephone number, age, sex, etc.. And
> as they pick up the information they display it in text boxes. The text
> boxes are display only, and the info is displayed only for debugging
> purposes.
>
> Right now I have a lot of duplicate code in these several applications.
> What I'd like to do is create one something, a class library or a user
> control, which eliminates all of the duplicate code. So this "something"

as
> I envision it will be a collection of labels and textboxes (tbxName,

tbxTel,
> tbxSex, etc.) and a class with corresponding fields (Name, Telephone, Sex,
> etc.). The something should also contain related subroutines such as the
> code which opens, writes, and closes the Excel spreadsheet.
>
> I wasn't sure if I needed a user control or a class library, but I have
> opted for the user control because I want to be able to plonk down the
> collection of labels and text boxes during the design of the consuming
> applications.
>
> I am now at the point where I have a bunch of labels and text boxes

defined
> on my "UserControl1.vb[Design]* tab. And now I am trying to define a

class
> of corresponding fields. So following my "Windows Form Designer generated
> code" I have ...
>
> Public Class Person
>
> Private mpName As String
>
> Public Property Name() As String
>
> Get
>
> Return mpName
>
> End Get
>
> Set(ByVal Value As String)
>
> mpName = Value
>
> UserControl1.tbxName = Value '<<<<< this is where I have a problem
>
> End Set
>
> End Property
>
> ...
>
> If it matters, note that this Person class is nested within the Public

Class
> UserControl1. I didn't know classes can be nested but I guess I do now.
>
> I suspect that I am really not going about this in the right way at all.
> But, if I am, then my problem is that I do not know how to specify the
> controls which correspond to my fields. You'll see above that I tried
> UserControl1.tbxName which I knew was wrong, but it at least conveys what

I
> am trying to do. I had high hopes for me.tbxName but that did not work
> either.
>
> So ... any advice or pointers you can share with me will be greatly
> appreciated.
>
> Thanks, Bob
>
>



 
Reply With Quote
 
eBob.com
Guest
Posts: n/a
 
      20th Feb 2006
Thank you Cerebrus. I make that mistake so often (i.e. typing tbxWhatEver =
SomeString instead of tbx.WhatEver.Text = SomeString).

I am making progress now.

Thanks again, Bob

"Cerebrus99" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi eBob
>
> You could consider creating both a Class Library (which contains all your
> business logic and properties) and a UserControl (which contains all UI
> elements.) and then link both of them together. There is of course the
> option of nesting everything within one class, but it's not very good
> coding
> practice in my opinion, especially considering that the Reusability
> requirement in your project is high.
>
> As for the confusion about whether to use a Class Library or UserControl,
>
> By Definition :
> - A Class Library template is used to quickly create reusable classes and
> components that can be shared with other projects.
>
> - The UserControl provides an empty control that can be used to create
> other
> controls, and gives you the ability to create controls that can be used in
> multiple places within an application.
>
> So, to summarize, the Class library should contain all the logic by which
> you load data, it will have properties and methods, while your UserControl
> should handle the displaying of the data in the TextBoxes.
>
>> UserControl1.tbxName = Value '<<<<< this is where I have a problem

>
> I fail to understand what exactly you are trying to do by this statement.
> You are equating a Control (texbox) with a string value, which won't work.
> I'm assuming that you want to change the text of the Textbox here.
>
> if tbxName is the name of a TextBox, then to change it's text, just do :
> tbxName.Text = MyClass.PropertyName
> where MyClass is the name of your ClassLibrary and PropertyName is the
> name
> of the relevant property.
>
> I would recommend that you check up on some tutorials on the web or MSDN,
> which will clear these concepts.
>
> Lemme know if you need more info,
>
> Regards,
>
> Cerebrus.
>
>
>
> "eBob.com" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I have several applications which mine web sites for personal information
>> which they publish. They publish the info in one form, I transform the

> info
>> into Excel spreadsheets.
>>
>> So all these programs pick up name, telephone number, age, sex, etc..
>> And
>> as they pick up the information they display it in text boxes. The text
>> boxes are display only, and the info is displayed only for debugging
>> purposes.
>>
>> Right now I have a lot of duplicate code in these several applications.
>> What I'd like to do is create one something, a class library or a user
>> control, which eliminates all of the duplicate code. So this "something"

> as
>> I envision it will be a collection of labels and textboxes (tbxName,

> tbxTel,
>> tbxSex, etc.) and a class with corresponding fields (Name, Telephone,
>> Sex,
>> etc.). The something should also contain related subroutines such as the
>> code which opens, writes, and closes the Excel spreadsheet.
>>
>> I wasn't sure if I needed a user control or a class library, but I have
>> opted for the user control because I want to be able to plonk down the
>> collection of labels and text boxes during the design of the consuming
>> applications.
>>
>> I am now at the point where I have a bunch of labels and text boxes

> defined
>> on my "UserControl1.vb[Design]* tab. And now I am trying to define a

> class
>> of corresponding fields. So following my "Windows Form Designer
>> generated
>> code" I have ...
>>
>> Public Class Person
>>
>> Private mpName As String
>>
>> Public Property Name() As String
>>
>> Get
>>
>> Return mpName
>>
>> End Get
>>
>> Set(ByVal Value As String)
>>
>> mpName = Value
>>
>> UserControl1.tbxName = Value '<<<<< this is where I have a problem
>>
>> End Set
>>
>> End Property
>>
>> ...
>>
>> If it matters, note that this Person class is nested within the Public

> Class
>> UserControl1. I didn't know classes can be nested but I guess I do now.
>>
>> I suspect that I am really not going about this in the right way at all.
>> But, if I am, then my problem is that I do not know how to specify the
>> controls which correspond to my fields. You'll see above that I tried
>> UserControl1.tbxName which I knew was wrong, but it at least conveys what

> I
>> am trying to do. I had high hopes for me.tbxName but that did not work
>> either.
>>
>> So ... any advice or pointers you can share with me will be greatly
>> appreciated.
>>
>> Thanks, Bob
>>
>>

>
>



 
Reply With Quote
 
Cerebrus
Guest
Posts: n/a
 
      20th Feb 2006
> I am making progress now.
>
> Thanks again, Bob



Good to hear that ! :-)

Regards,

Cerebrus.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class Library Versus Control Library Darren Microsoft Dot NET Compact Framework 2 23rd Apr 2007 02:27 AM
Re: Difference between Web Control Library and Class Library Alan Ferrandiz [MCT] Microsoft ASP .NET 0 11th Sep 2004 02:51 PM
Re: Difference between Web Control Library and Class Library David Jessee Microsoft ASP .NET 0 25th Aug 2004 12:49 PM
Re: Difference between Web Control Library and Class Library Mythran Microsoft ASP .NET 0 24th Aug 2004 06:53 PM
Custom Control (windows Control Library) or Class Library tiger79 Microsoft Dot NET Compact Framework 2 5th May 2004 03:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 AM.