473,588 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use field name as a parameter in a subroutine or function

I have an application with many combobox in different forms used for
choose a particular length (for example items are "ft" - feet, "in" -
inch, "m" - meters, and so on).
I don't want to put in every form (class), in load event, the code
needed to load items from a Db table using items.add.
I want to create a public subroutine (or function), when i call it I
pass, as a parameters, the form and field name, then the subroutine
read from the table and add items in the form/field I have passed as
parameters.
I don't know if I can do that and how.
Any suggestion?

Nov 9 '07 #1
1 2180
On Nov 9, 9:51 am, bassi.ca...@gma il.com wrote:
I have an application with many combobox in different forms used for
choose a particular length (for example items are "ft" - feet, "in" -
inch, "m" - meters, and so on).
I don't want to put in every form (class), in load event, the code
needed to load items from a Db table using items.add.
I want to create a public subroutine (or function), when i call it I
pass, as a parameters, the form and field name, then the subroutine
read from the table and add items in the form/field I have passed as
parameters.
I don't know if I can do that and how.
Any suggestion?
Your function should be in a module and probably look like this:

Public Sub AddItemsToCombo Box(byref combo as ComboBox,byval field as
String,byval table as String)
combo.items.cle ar()

'get the records from the database
combo.items.add (field & " from function")
combo.items.add ("another record")

end sub

and then you can call it like this:

public sub form_load(...)

AddItemsToCombo Box(ComboBox1," fieldname","tab lename")

end sub

That's all you should need to do. Adapt this as you need it :-)

Phill

Nov 9 '07 #2

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

Similar topics

1
2238
by: Hon Seng Phuah | last post by:
Hi, I am quite new to perl development and have a question very stupid question. I hope that someone can help me. Does perl support in/out parameter subroutine? Like in C/C++, we have a function callee: a(&b); // variable b value will be change in function a.
5
2991
by: j_liu21 | last post by:
Is something like this possible? A form with x fields named field1, field2, ... fieldx I'd like to set the field specified in the parameter function SetUnknownField(FieldID) { document.myform.field+FieldID+.value="Something calculated";
18
1968
by: NickName | last post by:
The following example may further clarify the question, Select fieldA, filedB, fieldC >From tblX Where fieldD = Forms!formName!controlName What I'd like to know is how to determine or get (FieldD) for the above SQL stmt, which is a saved query. Meantime, let me stress, I'm talking about query param(s), not criteria, an example of criteria is as follows: Select fieldA, filedB
6
1698
by: Jeff Frederick | last post by:
Hello all, I am interested in using the value from a field to call a function. For example I have a table and one of the field names is "Function." So for each record I input the name of the function I want to run when this record is selected. Table Example: Shape Function -------------------
3
1217
by: vipul DotNet | last post by:
hi friend, I have a function which can accept 2 parameters , one as any double value second as "Y" or "N" public sub abc(byval dblvalue as double,byval strvalue as string) end sub I want the subroutine to accept only "Y" or "N" as parameter else should
2
1209
by: Richard | last post by:
Hi. How can I pass a subroutine as a parameter to another subroutine? How would the formal parameter list needs to be declared in order to receive a rubroutine (address)? Thanks in advance, Richard
7
9554
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a subroutine Let's say theres a sub that creates buttons and I want it to receive as a parameter the address of the sub that handles the OnClick event for the button being created How do I pass such a parameter Thanks in advance Richar
2
14869
by: K B | last post by:
Hi, Is there ANY WAY to hide a row/field in a DetailsView based on meeting a condition at the ItemCreated or ModeChanging event -- or any other way? There appears not to be, but I was hoping for confirmation before totally giving up. Thanks, Kit
4
2889
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data. I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the...
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7862
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2372
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.