473,382 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

2 General .NET Questions

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
1 1472
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gcook | last post by:
Hi, I've got an old perl program running on my webserver - so old that I haven't used a perl programmer in about two years :) (we've gone all php for a variety of reasons). Anyway, I'm...
2
by: Ross Micheals | last post by:
All I have some general .NET questions that I'm looking for some help with. Some of these questions (like the first) are ones that I've seen various conflicting information on, or questions that...
9
by: pankaj_wolfhunter | last post by:
Hi, I need some clearance on the following questions: 1) Does LOAD command updates indexes defined for a table? 2) Is REPLACE option in the LOAD command a logged operation? Help will be...
1
by: jason | last post by:
Hello everyone, I have some general questions about the DataTable object, and how it works. Moderately new to C#, I have plenty of texts describing the language, but not so much to reference...
6
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to...
6
by: Andy | last post by:
Someone posted this official proposal to create comp.databases.postgresql.general again. He wrote his own charter. As far as I know, he did not consult any of the postgresql groups first. There...
4
by: Viviana Vc | last post by:
Hi all, I've read the WindowsVistaUACDevReqs.doc documentation and I have done different small tests on Vista to understand the bahaviour and now I have a few questions. 1) If I create a...
2
by: SpotNet | last post by:
Scott M. Have your experiences shown you that programmers may give the best computer advice, analysis, and solutions even at the worst of times, for a PC user? ;~D Haven't crossed many Network...
3
by: =?Utf-8?B?Ymxi?= | last post by:
I am posting to the general discussion group - but I cannot find my postings... or replies...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.