473,748 Members | 10,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

global variable

Hi, after reading up, c# doesnt appear to use gloal variables. Alot of
post advise against them also. So Im wondering how to get around this.
Im trying to do a calculation, retain the result, do another
calculation then add the result to my retained value etc. my values:
Im backing then laying horses. So I back first, say with a return of
£20 if it wins. Then I lay the horse with an offset bet giving me an
overall return of £1. Ok, so I need to retain this value, at the
momment I put it in textbox 'a'. Now say on the same horse I bet
again. Same bet £20 if it wins, except Ive got to add my £1 giving
£21. Ok so far, but I must retain the £20 outcome for this bet as it
is used to calculate the offset bet. Not the £21. At the momment Im
putting this figure into textbox 'b'. Ive written a class to do all
the calcs. These calcs are done when a button is clicked, so once
clicked the variables go out of focus, whence putting the values in a
text box. But this doesnt feel very proffesional. Also I have to use
another text box to retain the first odds backed a, so I can check
that the lay odds are smaller. Hope you get the jist. Can anybody
advise if there is a better way to do this.
Regards Robert

Jun 2 '07
13 2163
Rob,
after reading through this thread, it sounds to me that if you intend to
make your application really usable (or to sell it to others) then you need
to stop and think about how to store your data in some sort of database or
local file storage that gets reloaded when somebody restarts your
application.
When you get your first Martingale system running let me know and I'll buy a
copy.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Ro********@yah oo.co.uk" wrote:
Hi, after reading up, c# doesnt appear to use gloal variables. Alot of
post advise against them also. So Im wondering how to get around this.
Im trying to do a calculation, retain the result, do another
calculation then add the result to my retained value etc. my values:
Im backing then laying horses. So I back first, say with a return of
£20 if it wins. Then I lay the horse with an offset bet giving me an
overall return of £1. Ok, so I need to retain this value, at the
momment I put it in textbox 'a'. Now say on the same horse I bet
again. Same bet £20 if it wins, except Ive got to add my £1 giving
£21. Ok so far, but I must retain the £20 outcome for this bet as it
is used to calculate the offset bet. Not the £21. At the momment Im
putting this figure into textbox 'b'. Ive written a class to do all
the calcs. These calcs are done when a button is clicked, so once
clicked the variables go out of focus, whence putting the values in a
text box. But this doesnt feel very proffesional. Also I have to use
another text box to retain the first odds backed a, so I can check
that the lay odds are smaller. Hope you get the jist. Can anybody
advise if there is a better way to do this.
Regards Robert

Jun 2 '07 #11
Thankyou all for our replys. Plenty to work with now. Storing the data
is my next task, although martingale will not be the system. Simply
trying to trade the prices/money. Ive tried the static class and that
works. Going to try your suggestion also Mark. thanks again.
regards robert

Jun 3 '07 #12
<Ro********@yah oo.co.ukwrote in message
news:11******** *************@k 79g2000hse.goog legroups.com...

Robert,
Thankyou all for our replys. Plenty to work with now. Storing the data
is my next task, although martingale will not be the system. Simply
trying to trade the prices/money. Ive tried the static class and that
works. Going to try your suggestion also Mark. thanks again.
Please don't take this the wrong way, but OOP generally and classes
specifically are *absolutely fundamental* to C#...

You really would be well advised to get a copy of this:
http://www.amazon.com/C-2005-Dummies...0879762&sr=8-1

and work your way through it. Part 4 particularly will be of great benefit
to your particular requirements...

Without a basic grasp of how a C# app is structured, and what the various
bits do, you're really going to struggle...

Also, if you get into bad habits from the beginning, you'll find it much
more difficult to "unlearn" them in the future...
--
http://www.markrae.net

Jun 3 '07 #13
Totaly agree. No offence taken. Thats the good thing about asking
question, you soon find out how little you know.
Regards Robert

Jun 3 '07 #14

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

Similar topics

8
102756
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions> <instructions> def bar: <instructions>
4
24182
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); function loadUrlVariables() { varString = location.search;
4
7134
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
2
8831
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book { public: Book()
8
2558
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined in global space, therefore it is not a global variable, yes? Even if it was global, how would it get from one function to another? In PHP variables are copied by value. Are they copied by reference in Javascript? <SCRIPT LANGUAGE="JavaScript">
17
5627
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
10
2659
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of the more specialist aspects of the job but am now completely stuck on something I would have thought were simplicity itself... I need to have a large number of global variables visible inside functions - it's not possible to pass them into the...
9
3030
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
29372
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
112
5460
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
8984
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
8823
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
9530
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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
9312
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
8237
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3300
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

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.