473,395 Members | 1,404 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,395 software developers and data experts.

How do I restrict a user to enter a parameter in a list of values ?

Hi. A newbie question, please:

I have a function which gets some values from a database, based on a
CategoryName. My function looks like this:
Public Function GetProducts(ByVal CategoryName As String) As DataSet.

I would like to be able to restrict the user to enter only one of the
EXISTING categories - to behave in the same way IntelliSense behaves. For
instance if I had the categories "Category One" and "Category Two", the user
should only be able to select among one of those.

I created a module named "categories" with the intent to be able to declare
the function as
Public Function GetProducts(ByVal CategoryName As CategoriesList) As DataSet

I cannot use an enum, because I cannot enter the string "Category One" as a
valid member of the Enum (the name of the member has to be a valid VB name).

So I thought I could use a collection. I have now in a module named
"Categories.vb" a collection "CategoriesList":

Module Categories
Public CategoriesList As New Collection()
End Module

CategoriesList is filled like this:

Do While objDataReader.Read()
Categories.CategoriesList.Add(objDataReader("Categ oryName").ToString)
Loop

Now my problem is how do I change the signature of my function ? If I try to
write:
Public Function GetProducts(ByVal CategoryName As CategoriesList) As
DataSet, it says that CategoriesList is not defined as a type.

What am I doing wrong, please ?

Thank you, Alex
Nov 21 '05 #1
1 1097
Use combobox and set its dropdown property to dropdownlist. now pass
combobox1.text as string to the function :)
"Alex Nitulescu" <RE***********************@yahoo.com> wrote in message
news:ek**************@TK2MSFTNGP09.phx.gbl...
Hi. A newbie question, please:

I have a function which gets some values from a database, based on a
CategoryName. My function looks like this:
Public Function GetProducts(ByVal CategoryName As String) As DataSet.

I would like to be able to restrict the user to enter only one of the
EXISTING categories - to behave in the same way IntelliSense behaves. For
instance if I had the categories "Category One" and "Category Two", the
user should only be able to select among one of those.

I created a module named "categories" with the intent to be able to
declare the function as
Public Function GetProducts(ByVal CategoryName As CategoriesList) As
DataSet

I cannot use an enum, because I cannot enter the string "Category One" as
a valid member of the Enum (the name of the member has to be a valid VB
name).

So I thought I could use a collection. I have now in a module named
"Categories.vb" a collection "CategoriesList":

Module Categories
Public CategoriesList As New Collection()
End Module

CategoriesList is filled like this:

Do While objDataReader.Read()
Categories.CategoriesList.Add(objDataReader("Categ oryName").ToString)
Loop

Now my problem is how do I change the signature of my function ? If I try
to write:
Public Function GetProducts(ByVal CategoryName As CategoriesList) As
DataSet, it says that CategoriesList is not defined as a type.

What am I doing wrong, please ?

Thank you, Alex

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Vijay Kumar R Zanvar | last post by:
Greetings, Are the following inferences of mine correct? 1. #include <string.h> char *strcpy(char * restrict s1, const char * restrict s2); a. s1 != s2 b. That means,
7
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
12
by: sam | last post by:
hi all, i'm starting to put together a program to simulate the performance of an investment portfolio in a monte carlo manner doing x thousand iterations and extracting data from the results. ...
3
by: %NAME% | last post by:
Suppose I am an admin of a database instance. Now I need to specify that user A has the right to create tables in his own schema, but not anywhere else. In order to let user A create tables, i...
1
by: =?Utf-8?B?Qw==?= | last post by:
I want to restrict the user entering nonalphanumeric keys using Javascript onKeypress. One exception is that I want to allow the user to enter spaces. How can I do this? Thanks in Advance.
5
by: Dakrat | last post by:
Allow me to preface this post by saying that this is my first database project, and while I have learned a lot, any concepts I have learned are hit and miss as I have found new requirements and...
3
by: geebanga88 | last post by:
HI i want to create a month query that restricts the records by a month given that is inputed by a user from a form. There is an attribute in the relation called date which should only match the...
2
by: anwest75 | last post by:
Hi, I'm not a newb to Access but have recently migrated to 2007 and suddenly my method doesn't seem to work. I'm generating a service award report where I need to show only those employees hitting a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.