There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
bios black screen blue screen boot computer connection crash css dell display driver drivers email error excel firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem router slow sound startup trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Array Help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
03-Apr-2005, 06:38 AM #1
Solved: Array Help
Hi Guys
I have desgned a sort of cash dispensing machine for a project. I have to record the number of withdrawals and deposits per day so I have been told to use an array.
I have examples of arrays where you set the amount to be stored in it (Fixed I think) but nothing of ones where you store unlimited amounts ( Dynamic ?)
As I said, I need to store the withdrawals and deposits that take place all day and then need to total each of them so I can take away one from the other to get a figure of profit or gain.
So basically I need

1: To have an array to store all withdrawals Or deposits for the day ( these would be separate)
2: How do I add the withdrawals Or deposits all together ?

I have a feeling it may be a dowhile loop but just a guess.

By the way my lecturer is the type that believes it's better for you to find out things for yourself rather than help too much ! sheesssh !

Thanks Guys

Gus

PS Complete noob to VB so pleeese keep it simple (ish) lol cheers
Ciberblade's Avatar
Computer Specs
Community Moderator with 15,703 posts.
 
Join Date: Sep 2003
Location: Heart of the Bluegrass Ky
Experience: Mostly Harmless
03-Apr-2005, 10:42 AM #2
You could get the length of the array, then add the values by index -- so the loop would work in that instance. Something like:
int ArrSize = myArr.GetLength()

I believe I might have a project like this....but I will need to reload my VB.NET (it is .NET right?)
__________________
82,268
*AD-Aware*AIDA32*AVG-7*Filemon*Hijack This*PortMon*Process Explorer*TSG Forums menu*

Far righty-tighty Wingnut Libertarian ( ) - annoyingly free thinking with no tendency to agree on anything with anyone. - BF

If you wish...you can now come to church with me! A church that is NOT normal...a church for people who don't like 'church'
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
03-Apr-2005, 02:23 PM #3
Hi
No it is just Visual Basic

Cheers

Gus
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,566 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
03-Apr-2005, 03:18 PM #4
Gus why do the deposits and withdrawals have to be seperate as one should be + while the other should be minus in nature. Thus when you add them all up in the for/next or do/while loop the balance is worked out for you. Has your instructor told you to do it that way?
__________________
.
.
OBP
I do not give up easily
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
04-Apr-2005, 04:55 AM #5
Hi
Hiya
Sorry Buddy I didnt explain it properly

It works out like this: If A customer Witdraws money he gets a charge for it
Lets Say 50p. But if a customer deposits money he gets a bonus for it, lets say 10p. You can only withdraw or deposit once on any day (he isnt bothered about checking this) so if a 100 people withdraw in a day the total charges are £50.00 and if a 100 people deposit on the same day the bonuses are £10.00 and he wants to take one from the other so in reality the bank has made £40.00 profit.(As Such)
It is slightly more complicated as you have 3 different types of customers so the Charges/Bonuses are different, and the amount you withdraw/ deposit affects this as well, but I have sorted all that.
So I need to keep a running total of the charges and bonuses and take one from the other at the close of day and I'm not sure how to do it.( I do know how to take one from the other lol)
I have looked at arrays for storing figures, I have examples where you set the maxium number stored in the array, but I dont know how many transactions wil take place during the day, so I want it to be infinite really, and then I need to add them up,to enable the subtraction. (Or maybe you dont need an array)
Its a bit crap I think as it's made up by the tutor but I have to give him what he wants I suppose
Sorry for the essay But it's awkward doing it for the first time with so little help. I'm not a schoolkid looking to have it done i'm 45 and having a go at learning VB and most of the books I use seem to think you have been programming for years (Difficult then)
Anyway Cheers for the reply I hope it has made it clearer what he wants

Thanks a million I appreciate it.

Gus

PS Sorry if it turns out to be ridicolously easy
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,566 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
04-Apr-2005, 06:44 AM #6
Gus,
I would do it this way, one Dynamic variable for deposits and one for Withdrawals and 3 counters called counter, counter1 and count which are integers. The variable will contain the data as follows -
Dim value() as double, value2 as double, counter as integer, counter2 as integer, count aqs integer.
The counter is the entry number for deposits which keeps track of how many deposits are made, The value is the deposit amount. So it would look like this for entry 1 for £50
counter =1: Value(counter) = 50.00 for subsequent entries counter = counter + 1.
To sum the deposits use a for next loop -
For count = 1 to counter: totalvalue= totalvalue + Value(count): Next count
For withdrawals you can use counter2 and value2 as the variables and do exactly the same.
I am an old BASIC programmer and do not know the right terminology for VB6 but I hope this gives you the idea.
__________________
.
.
OBP
I do not give up easily

Last edited by OBP : 04-Apr-2005 07:42 AM.
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
04-Apr-2005, 02:09 PM #7
Cheers Butty Wlil give it a try and get back

Much App

Gus
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,566 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
04-Apr-2005, 02:18 PM #8
Gus, I have had a rethink on that, has your Instructor said you have to use an array, or can you just get the job done?
If you must use a multi-dimension array, I can probably help on that.
But there is an even simpler way to do this which negates the use of the For/next loop, although that is good practice programming for you.
When each entry is made you could just add the value to the totalvalue with totalvalue = totalvalue + value.
It really depends on what your instructor is asking you to do.
__________________
.
.
OBP
I do not give up easily
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
05-Apr-2005, 04:25 AM #9
hiya
He has no particular preference, he has left it up to me.
So will this method actually add up the total everytime?, it looks like it will and if so problem sorted. We have a kid in the class who comes across as a boffin and he has been going on about "must use an array" so we have all been panacking.To be honest I have seen this total example before.
I will try it out on a form just as a test.
Thanks again mate I really appreciate the help

Gus
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,566 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
05-Apr-2005, 06:53 AM #10
Gus, anytime
GUSMAN's Avatar
Senior Member with 721 posts.
 
Join Date: Dec 2001
Location: WALES
08-Apr-2005, 08:47 AM #11
Hi OBP Mate
Just to let you know it worked fine.
It didnt at first as it kept totalling the withDrawals and deposits and not separately , then I noticed your earlier thread and named the counter"2" and value2, I named them the same in each command button before so its no wonder it totalled the both.
I have learnt somethingwith your help and as I said before I really Appreciate it.
I am more chuffed than when Wales Beat England in the 6 Nations ( welllllllll maybe not quite lol)
Take Care mate
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 6,566 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
08-Apr-2005, 01:30 PM #12
Gus, can you mark the thread as "Solved" please using the Thread Tools at the top of the Forum page.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:26 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.