473,569 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to pass a variable to another class by using c#?

15 New Member
hi mate! i'm showing just a part of my source code. i need to pass the 'GetSeconds' variable to my SqlDB. can somebody show me how to pass it? what should i need to add in? thanks for the kindly help..

namespace test
{
public partial class test : Form
{
private long GetSeconds(int hour, int minutes)
{
if ((hour != 0) && (minutes!=0))
return ((hour*3600) + (minutes * 60));
else if (hour != 0)
return (hour * 60 * 60);
else
return (minutes * 60);
}
}
}


namespace test
{
class SqlDB
{
private void RecoverSchedule ()
{
switch (Convert.ToInt3 2(myReader.GetV alue(myReader.G etOrd inal("Interval_ Type"))))
{
case 1:
Interval = GetSeconds(0, Convert.ToInt32 (myReader.GetVa lue(myReader.Ge tOrdi nal("Interval_T ime"))));
break;
}
}
}
Mar 7 '08 #1
2 1877
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
GetSeconds looks like a method (rather than a variable)

Moreover the value that GetSeconds Returns is stored into Interval.

You have to either use and update or insert statement to update the database accordingly.
Mar 7 '08 #2
lazzypink
15 New Member
GetSeconds looks like a method (rather than a variable)

Moreover the value that GetSeconds Returns is stored into Interval.

You have to either use and update or insert statement to update the database accordingly.
hi! thanks. i'm sorry didn't state my Question clearly. i just wonder how to pass the GetSeconds from my test class to my sqlDB class where the underlined GetSeconds what should i add on?? is it "test.GetSecond s"? i try before but is an error....can you show me the correct answer? thanks!
Mar 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2054
by: Doug Jordan | last post by:
I am fairly new to Python. This should be an easy answer but I cannot get this to work. The code is listed below. I know how to do this in C, Fortran, and VB but it doesn't seem to work the same way here. I would appreciate any help. #try this to pass a list to a function and have the function return #a variable #this works list= def...
11
8786
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
4
3381
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another function call funcRet()is made which returns the expected argument type for the function call by reference funcByRef(class A&); The only way to get...
4
3397
by: z_learning_tester | last post by:
I'm reading the MS press C# book and there seems to be a contradiction. Please tell me which one is correct, 1 or 2. Thanks! Jeff 1. First it gives the code below saying that it prints 0 then 42. They say that 42 is printed the second time since the value was wrapped in a class and therefore became passed by reference. (sorry for any...
8
6568
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable, and then I had other usercontrols simply read this by traversing the class structure: siteClass.userControlClass.specficVariable. That worked fine....
6
2030
by: Mike Hoff | last post by:
I am trying to write a class that will store info about database fields for building UPDATE / INSERT commands later on. I cannot seem to get the sytax correct to pass and store the data type of the field. My class looks like: Public Class DataTag Private m_Text As String Private m_FieldName As String Private m_ParamName As String...
5
7807
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into a WebService is that essentially we are passing an address of an object which resides on the 'local machine' i.e. a local machine object address....
9
12809
by: mps | last post by:
I want to define a class that has a generic parameter that is itself a generic class. For example, if I have a generic IQueue<Tinterface, and class A wants to make use of a generic class that implements IQueue<Tfor all types T (so it can make use of queues of various object types internally). As useful as this is, it doesn't seem possible. The...
12
3000
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope. The global variables and global functions are hidden to prevent from accessing by the programmers. All global functions share global variables....
12
11039
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed!...
0
7612
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...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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...
0
7964
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...
0
6281
agi2029
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
1209
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.