I have about 10 functions that are identical except for one variable name
that I am using in my "for" loop:
for (ktr1=1;ktr1<=n hDataBean.proje ctCodeList.GetU pperBound(0);kt r1++)
for (ktr1=1;ktr1<=n hDataBean.shift CodeList.GetUpp erBound(0);ktr1 ++)
for (ktr1=1;ktr1<=n hDataBean.statu sCodeList.GetUp perBound(0);ktr 1++)
How can I change the "nhDataBean.xxx .GetUpperBound( 0)" so that I can use
only one function?
The code functions and how they are called:
*************** *************** *************** *************** ****
public void GetProjects(Dat aTable dt)
{
int ktr1 = 0;
DataRow dr;
// Add the columns to the DataTable's Columns collection
dt.Columns.Add( "code");
dt.Columns.Add( "descriptio n");
for (ktr1=1;ktr1<=n hDataBean.proje ctCodeList.GetU pperBound(0);kt r1++)
{
dr = dt.NewRow();
dr["code"] = nhDataBean.proj ectCodeList[ktr1][0];
dr["descriptio n"] = nhDataBean.proj ectCodeList[ktr1][1];
dt.Rows.Add(dr) ;
}
}
public void GetShifts(DataT able dt)
{
int ktr1 = 0;
DataRow dr;
// Add the columns to the DataTable's Columns collection
dt.Columns.Add( "code");
dt.Columns.Add( "descriptio n");
for (ktr1=1;ktr1<=n hDataBean.shift CodeList.GetUpp erBound(0);ktr1 ++)
{
dr = dt.NewRow();
dr["code"] = nhDataBean.shif tCodeList[ktr1][0];
dr["descriptio n"] = nhDataBean.shif tCodeList[ktr1][1];
dt.Rows.Add(dr) ;
}
}
public void GetStatus(DataT able dt)
{
int ktr1 = 0;
DataRow dr;
// Add the columns to the DataTable's Columns collection
dt.Columns.Add( "code");
dt.Columns.Add( "descriptio n");
for (ktr1=1;ktr1<=n hDataBean.statu sCodeList.GetUp perBound(0);ktr 1++)
{
dr = dt.NewRow();
dr["code"] = nhDataBean.stat usCodeList[ktr1][0];
dr["descriptio n"] = nhDataBean.stat usCodeList[ktr1][1];
dt.Rows.Add(dr) ;
}
}
public DataSet GetCompanyHRInf o()
{
GetProjects(ds. Tables.Add("Pro jects"));
GetShifts(ds.Ta bles.Add("Shift s"));
GetStatus(ds.Ta bles.Add("Statu s"));
return ds;
}
*************** *************** *************** *************** ***
Thanks,
Tom 3 1318
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OV******** ******@TK2MSFTN GP04.phx.gbl... I have about 10 functions that are identical except for one variable name that I am using in my "for" loop:
for (ktr1=1;ktr1<=n hDataBean.proje ctCodeList.GetU pperBound(0);kt r1++) for (ktr1=1;ktr1<=n hDataBean.shift CodeList.GetUpp erBound(0);ktr1 ++) for (ktr1=1;ktr1<=n hDataBean.statu sCodeList.GetUp perBound(0);ktr 1++)
How can I change the "nhDataBean.xxx .GetUpperBound( 0)" so that I can use only one function?
The code functions and how they are called:
Easy I hope :)
public void GetWhateverYouW antThisNamed(Da taTable dt, object[] items)
{
...
for (...;ktr1 <= items.GetUpperB ound(0); ktr1++)
...
}
It would be better if we knew the type for projectCodeList , shiftCodeList,
and statusCodeList. If they are all the same array type, you could use the
object type instead of "object[]"...
HTH :)
Mythran
"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. .. "tshad" <ts**********@f tsolutions.com> wrote in message news:OV******** ******@TK2MSFTN GP04.phx.gbl...I have about 10 functions that are identical except for one variable name that I am using in my "for" loop:
for (ktr1=1;ktr1<=n hDataBean.proje ctCodeList.GetU pperBound(0);kt r1++) for (ktr1=1;ktr1<=n hDataBean.shift CodeList.GetUpp erBound(0);ktr1 ++) for (ktr1=1;ktr1<=n hDataBean.statu sCodeList.GetUp perBound(0);ktr 1++)
How can I change the "nhDataBean.xxx .GetUpperBound( 0)" so that I can use only one function?
The code functions and how they are called:
Easy I hope :)
public void GetWhateverYouW antThisNamed(Da taTable dt, object[] items) { ... for (...;ktr1 <= items.GetUpperB ound(0); ktr1++) ... }
It would be better if we knew the type for projectCodeList , shiftCodeList, and statusCodeList. If they are all the same array type, you could use the object type instead of "object[]"...
The objects are actually string[][] objects.
Setting it up your way (but using string instead of objects as you
suggested), looks like this:
*************** *************** *************** *************** ***
public void GetHomeStateSta tus2(DataTable dt, string[][] items)
{
int ktr1 = 0;
DataRow dr;
// Add the columns to the DataTable's Columns collection
dt.Columns.Add( "code");
dt.Columns.Add( "descriptio n");
for (ktr1=1;ktr1<=i tems.GetUpperBo und(0);ktr1++)
{
dr = dt.NewRow();
dr["code"] = items[ktr1][0];
dr["descriptio n"] = items[ktr1][1];
dt.Rows.Add(dr) ;
}
}
*************** *************** *************** *************** ****
This is called like so:
GetHomeStateSta tus2(ds.Tables. Add("HomeStateS tatus"),etDataB ean.homeStateSt atus);I am getting the error:[NullReferenceEx ception: Object reference not set to an instance of anobject.] MyFunctions.New Hire.GetWorkSta teStatus2(DataT able dt, String[][] items) MyFunctions.New Hire.AddNewHire FW()I know the data is there, it shows in the debugger as:+ homeStateStatus {Length=6} string[][]If I replace the items in the functions with etDataBean.home StateStatus, itworks fine.Thanks,Tom >> HTH :)>> Mythran
Never mind.
I got it recompiled and it started to work. I must not have copied the DLL
correctly.
So the string[][] worked fine.
Thanks,
Tom
"tshad" <ts**********@f tsolutions.com> wrote in message
news:eJ******** ********@TK2MSF TNGP03.phx.gbl. .. "Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message news:%2******** ********@TK2MSF TNGP03.phx.gbl. .. "tshad" <ts**********@f tsolutions.com> wrote in message news:OV******** ******@TK2MSFTN GP04.phx.gbl...I have about 10 functions that are identical except for one variable name that I am using in my "for" loop:
for (ktr1=1;ktr1<=n hDataBean.proje ctCodeList.GetU pperBound(0);kt r1++) for (ktr1=1;ktr1<=n hDataBean.shift CodeList.GetUpp erBound(0);ktr1 ++) for (ktr1=1;ktr1<=n hDataBean.statu sCodeList.GetUp perBound(0);ktr 1++)
How can I change the "nhDataBean.xxx .GetUpperBound( 0)" so that I can use only one function?
The code functions and how they are called:
Easy I hope :)
public void GetWhateverYouW antThisNamed(Da taTable dt, object[] items) { ... for (...;ktr1 <= items.GetUpperB ound(0); ktr1++) ... }
It would be better if we knew the type for projectCodeList , shiftCodeList, and statusCodeList. If they are all the same array type, you could use the object type instead of "object[]"...
The objects are actually string[][] objects.
Setting it up your way (but using string instead of objects as you suggested), looks like this:
*************** *************** *************** *************** *** public void GetHomeStateSta tus2(DataTable dt, string[][] items) { int ktr1 = 0; DataRow dr; // Add the columns to the DataTable's Columns collection dt.Columns.Add( "code"); dt.Columns.Add( "descriptio n");
for (ktr1=1;ktr1<=i tems.GetUpperBo und(0);ktr1++) { dr = dt.NewRow(); dr["code"] = items[ktr1][0]; dr["descriptio n"] = items[ktr1][1]; dt.Rows.Add(dr) ; } } *************** *************** *************** *************** ****
This is called like so:
GetHomeStateSta tus2(ds.Tables. Add("HomeStateS tatus"),etDataB ean.homeStateSt atus);I am getting the error:[NullReferenceEx ception: Object reference not set to an instance of anobject.] MyFunctions.New Hire.GetWorkSta teStatus2(DataT able dt, String[][] items) MyFunctions.New Hire.AddNewHire FW()I know the data is there, it shows in the debugger as:+ homeStateStatus {Length=6} string[][]If I replace the items in the functions with etDataBean.home StateStatus, itworks fine.Thanks,Tom >> HTH :)>> Mythran This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nick |
last post by:
I am working a new application...well actually a series of applications for
my company. They want internal users to be able to go to a site and
everything regarding security is transparent, however we will have brokers
and customers that also need to connect and will require a username and
password. In this case we were going to store their credentials in a SQL
database. Internal users will have the ability to access the same resources...
|
by: William Stacey [MVP] |
last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ
rooted path (similar to a VDir in IIS). Path.Combine alone will not do the
job in all cases. I also need to be sure the no funny business can go on in
the passed "path" that would produce a path not in the root (i.e.
"..\..\dir1"). Here is my first stab at it, but not sure if this is too
much or not enouph to ensure this. Any thoughts are welcome. TIA.
///...
|
by: steve_h |
last post by:
I think the subject says it all, but just in case:
I know that I can call my own methods during an XSL transformation
using
<xsl:value-of select="myObject.someMethod(arg1)" />
having done something like:
dim xslTrans as System.Xml.Xsl.Xsltransform
|
by: Luvin lunch |
last post by:
Hi,
I'm new to access and am very wary of dates as I have limited
experience in their manipulation and I know if they're not done
properly things can turn ugly quickly.
I would like to use a calendar control to allow my users to enter a
date but I need them to enter a time as well. It doesn't look like the
calendar control will allow times to be entered so I was thinking of
having two text boxes. One text box would contain the date...
|
by: Schroeder, AJ |
last post by:
Hello group,
I am a relative PHP newbie and I am trying to combine two arrays together,
but I also need to keep the keys of one array intact. What I am doing is two
SNMP walks against a Cisco router in which I expect the script to return the
interface number along with a small description of the interface type, like
this:
Array
(
| |
by: nugz |
last post by:
I want to combine 3 tables with like data then append it with a filter.
Tables: NewStarts, Complaints, Memos
Combine: Date, Address, Route, Pub, etc....
Then sort: previous 8 days, pub/freq for that day etc...
I can already do the append filter, but I cant combine and then append.
I tried a Union and did the combine.. but lack the part to append the union.
|
by: LSGKelly |
last post by:
Hi all. I need to combine two fields that contain numbers that are in a currency format (Ex: $1,500 $3,500). When I combine them, I want them to look like this -- $1,500/$3,500. When I combine them in the query, they look like this 1500/3500. Is there a way to combine and retain the currency format?
Thank you!
Kelly
|
by: macca |
last post by:
Hi,
I'm doing an two ldap_search queries and I need to combine the two
results into one single array containing all the results from each but
removing duplicates.
I have tried built in php functions such as array_merge (which gives
me duplicates) and array_unique which does not work either.
|
by: fjm |
last post by:
I have one jquery function that submits data via a datastring to my server. This works great. On success, I currently have a little alert box that lets the user know that the data was stored.
I now have a second function that gets back a json response for a success or failure from the server and will echo to the user whether the data was saved successfully or not. This function should replace the alert box in the bottom most function.
I...
|
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...
|
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,...
| |
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |