By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

2 General .NET Questions

P: n/a
Hello all,

I am fairly new to .NET, but not to VB. I have a couple of questions.

1. Shared Code Base
I have a solution with several different applications within it. Many of
the applications perform similar functions, such as checking data values for
nulls, or building formatted strings. I have created a module (General
Functions.vb) to contain these. However, when I add the module as an
existing file to my project, .NET's IDE appears to copy the file into the
current code directory. Therefore, each of my applications end up with a
new instance of the module. If I then change a routine, or add one to the
one in the current application, other applications don't see the changes.
Is there a way to link to a module from a common location such that all
applications will use the same instance, instead of individual instances for
all?

2. Obects In A Listbox.
Here is a question that I am fielding becuase I don't have enough time to
fight over it if it doesn't work.
I have created a custom control that searches through a database
containing geocoded address information. As such, it has several
properties, such as street number, street name, city, X, Y, postal code,
zone, etc. There are about 15 properties in all that are required for my
application.
In my application, a user can register multiple addresses (up to 10) for
his or her use. Therefore, for each customer in my Customers database,
there may be up to 10 addresses in a seperate table that are keyed on the
customer.
From a UI perspective, I have a single address search control, and a
listbox to which the user can add the address found by the control. The
listbox only shows general information such as street number and street name
for each item. However, I need to be able to store with each list item the
entire set of properties.
Using .NET, can I add a copy of the control in its current state as the
equivalent of ItemData? I know that .NET no longer supports this, so I have
gone through the process of creating a class with a text and integer
property for other uses. I guess what I would be trying to do is the same
thing in principle, that being a class that contains a text property, and a
object property that I could pass an entire instance of the address control
into By Value. If I later change the properties of the control on in the
UI, I need the copy stored with the list item to remain as it was when it
was copied in.

Sorry for the length, and thanks for the help,

Andrew MacLean
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
1) You should put the shared code into a new project (Class Library), so it
compiles into a DLL. Then from your client projects, you should add a
reference that that dll so you'll be able to use the shared code. In my
opinion this is the "cleanest" way to accomplish this.

2) You can put any object inside a listbox, even custom classes. So you can
create a custom class for the data you want to put in the listbox, make sure
you override the ToString method (this will be shown to the user).

Public Class Customer
Private _name As String
Private _street As String

Public Overrides Function ToString() As String
Return Me.Name & " " & Me.Street
End Function

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Street() As String
Get
Return _street
End Get
Set(ByVal value As String)
_street = value
End Set
End Property
End Class

You could use this code as follows:
Dim a As New Customer
a.Name = "a"
a.Street = "sa"

Dim b As New Customer
b.Name = "b"
b.Street = "bs"

ListBox1.Items.Add(a)
ListBox1.Items.Add(b)
--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"Andrew MacLean" <an***********@sympatico.ca> wrote in message
news:ub**************@TK2MSFTNGP11.phx.gbl...
Hello all,

I am fairly new to .NET, but not to VB. I have a couple of questions.

1. Shared Code Base
I have a solution with several different applications within it. Many of the applications perform similar functions, such as checking data values for nulls, or building formatted strings. I have created a module (General
Functions.vb) to contain these. However, when I add the module as an
existing file to my project, .NET's IDE appears to copy the file into the
current code directory. Therefore, each of my applications end up with a
new instance of the module. If I then change a routine, or add one to the
one in the current application, other applications don't see the changes.
Is there a way to link to a module from a common location such that all
applications will use the same instance, instead of individual instances for all?

2. Obects In A Listbox.
Here is a question that I am fielding becuase I don't have enough time to fight over it if it doesn't work.
I have created a custom control that searches through a database
containing geocoded address information. As such, it has several
properties, such as street number, street name, city, X, Y, postal code,
zone, etc. There are about 15 properties in all that are required for my
application.
In my application, a user can register multiple addresses (up to 10) for
his or her use. Therefore, for each customer in my Customers database,
there may be up to 10 addresses in a seperate table that are keyed on the
customer.
From a UI perspective, I have a single address search control, and a
listbox to which the user can add the address found by the control. The
listbox only shows general information such as street number and street name for each item. However, I need to be able to store with each list item the entire set of properties.
Using .NET, can I add a copy of the control in its current state as the
equivalent of ItemData? I know that .NET no longer supports this, so I have gone through the process of creating a class with a text and integer
property for other uses. I guess what I would be trying to do is the same
thing in principle, that being a class that contains a text property, and a object property that I could pass an entire instance of the address control into By Value. If I later change the properties of the control on in the
UI, I need the copy stored with the list item to remain as it was when it
was copied in.

Sorry for the length, and thanks for the help,

Andrew MacLean

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.