|
-
Jun 8th, 2002, 10:21 AM
#1
Thread Starter
New Member
Beginner help with arrays
I'm a begining programmer and I am having some trouble with arrays.
I have a program that uses a form_load to populate an array with some
checking accounts and then I need to search the array for a given
account number and return the account balance.
If the account number isn't found, a message box appears with an
error message.
I have successfully written the loop to search the array and return
the balance, but it keeps testing the other instances in the array.
For example, if
accounts(4) = (acctNo as Double, balance as Double,
overdraftProtection as Boolean)
accounts(0) = (101,100,false)
accounts(1) = (102,150,true)
accounts(2) = (103,180,false)
accounts(3) = (106,100,true)
accounts(4) = (107,130,false)
If I search the array for account 101 it displays the balance and
then gives me 4 error messages. I want it to stop searching when it
finds the account, and not display the error if it finds the account
number.
Thanks
Randy
-
Jun 8th, 2002, 10:24 AM
#2
Stuck in the 80s
accounts(4) = (107,130,false) You can't setup an array like that?
-
Jun 8th, 2002, 10:24 AM
#3
U aren't really clear... how bout the complete code in Form_Load with the exact error messages
-
Jun 8th, 2002, 10:32 AM
#4
Thread Starter
New Member
clarification
this is part of a VB.Net GUI class assignment.
This is the part of the question as posed to me:
2. In the Form Load event, create 5 CheckingAccounts with the following information. Populate a 5-element array to reference your checking accounts.
Number Balance OverdraftProtection
101 $150 False
102 $250 True
233 $50 False
321 $25 True
098 $155 False
I've done that.
3. Record Deposit.
a.Search the array to find the appropriate account – if no matching account is found, display an error message in a message box.
I have the search working. But it doesn't stop after finding the acct no. It contiues the search 4 more times and the returns a message box that I created saying the no. wasn't found.
-
Jun 8th, 2002, 10:36 AM
#5
Stuck in the 80s
Maybe you should post in the VB.Net forum then?
-
Jun 8th, 2002, 10:46 AM
#6
In my understanding.. there is no difference in synthax/language between .Net and prior versions of VB. Why don't you put the code of the whole search procedure here.
-
Jun 8th, 2002, 11:03 AM
#7
Stuck in the 80s
Originally posted by Yash_Kumar
In my understanding.. there is no difference in synthax/language between .Net and prior versions of VB.
You're understanding incorrectly. Visual Basic was completely rewritten from the ground up in .Net
-
Jun 8th, 2002, 11:06 AM
#8
But the basic language remains the same! Don't tell me Micro$oft made a totally new language??
-
Jun 8th, 2002, 11:14 AM
#9
Stuck in the 80s
Visual Basic .NET is substantially different from earlier versions. It builds applications for the .NET Framework, a run-time layer with improved security and reliability. In order to achieve this, Microsoft made numerous changes to the language. Most of these are beneficial, including full object orientation with inheritance, but the new Visual Basic is not compatible with the old. To migrate an old project you use an upgrade wizard, followed by manual fine-tuning. Applications built with Visual Basic .NET no longer support Windows 95, while for development, Windows NT 4.0, 2000, or XP is needed.
Also found this interesting review:
I purchased Microsoft Visual Basic.NET Standard under the misinformation that I was getting an actual functioning development package. I also purchased a book to help me get started "Using MS Visual Basic.NET" from Que. It was only after I attempted to work through the web application example did I find the problem. I only received a small portion of the program, which did not even let me work though the simple examples in the book.
Not only did I need the "Professional" version to perform any of the examples shown in the book; I needed to upgrade my operating system from XP Home Edition to XP Professional. This fact was well hidden in the documentation. In fact, it was only when I tried to install some missing files did I find that I could not create web applications. I could not create DLL's. I couldn't do a lot of the basic functions.
So in order to just use the program as advertised, I would need to spend another [$]+ to upgrade to the Professional version of VB and another [$] for XP Professional. Sure with rebate, it is "only" [$], but I am already into it for [$] for the VB.NET Standard.
The advertisement on the box states that I can upgrade my VB 6 applications, create XML documents, create class libraries. I can't even work through the simple examples, because the tools are not included.
Don't bother purchasing this edition. It may be a great product for the professional programer, but it is priced out of the league for the rest of us mortals.
Last edited by The Hobo; Jun 8th, 2002 at 11:18 AM.
-
Jun 8th, 2002, 01:08 PM
#10
I wonder how many charact
Its sounds like u need a in your loop when u find the account.
-
Jun 8th, 2002, 01:12 PM
#11
I wonder how many charact
VBFORUM TIPS:
7. Keep your Sigs to a minimum, so we can understand where your post ends...
-
Jun 8th, 2002, 04:57 PM
#12
Stuck in the 80s
Originally posted by nemaroller
VBFORUM TIPS:
7. Keep your Sigs to a minimum, so we can understand where your post ends...
Mine isn't that long...and it seems like a personal issue if you can't find out where post end. Go look at crptc's sig or some other people's. Just as long. Now bite me.
-
Jun 9th, 2002, 10:57 AM
#13
I wonder how many charact
Sorry about your sensitivity, perhaps if you realize that seeing an advertisement 6 times on one page is a little excessive and does nothing for people trying to find a solution...
-
Jun 9th, 2002, 12:04 PM
#14
VB.net was not written from scratch. Long sigs with pictures et al are a pain in the ass.
That's that done with.
4 error messages from one statement eh? Thats a real achievement! Well played 
accounts(4) = (acctNo as Double, balance as Double,
overdraftProtection as Boolean) makes no sense whatsoever.
It would make sense if the part to the right of the "=" was a description of a UDT, but you havent specified this.
Give code.
-
Jun 9th, 2002, 12:09 PM
#15
New Member
This could be a solution:
Dim I as integer
Dim AnswerBalance as long
For I = 0 to 4
do until accounts(I).acctNo = 101
AnswerBalance = accounts(I).balance
end do
next I
Comments: You search the array using I as index, you must
compare the account number in the array which is identified as
accounts(I).acctNo with the value of the account that you are looking for, once the account is found the loops ends because the
condition of ..do until.........
Best regards
-
Jun 9th, 2002, 01:25 PM
#16
Stuck in the 80s
Originally posted by nemaroller
Sorry about your sensitivity, perhaps if you realize that seeing an advertisement 6 times on one page is a little excessive and does nothing for people trying to find a solution...
Then why don't you shut them off?
-
Jun 9th, 2002, 10:42 PM
#17
I wonder how many charact
I would if I could just remove you only...
-
Jun 10th, 2002, 09:58 AM
#18
Stuck in the 80s
Originally posted by nemaroller
I would if I could just remove you only...
Stop complaining. My sig isn't even half the size of some others. Go bug them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|