Results 1 to 18 of 18

Thread: Beginner help with arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    2

    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

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    accounts(4) = (107,130,false) You can't setup an array like that?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Yash_Kumar
    Guest
    U aren't really clear... how bout the complete code in Form_Load with the exact error messages

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    2

    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.

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Maybe you should post in the VB.Net forum then?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Yash_Kumar
    Guest
    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.

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Yash_Kumar
    Guest
    But the basic language remains the same! Don't tell me Micro$oft made a totally new language??

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Its sounds like u need a
    VB Code:
    1. Exit For
    in your loop when u find the account.

  11. #11
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    VBFORUM TIPS:

    7. Keep your Sigs to a minimum, so we can understand where your post ends...

  12. #12
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  13. #13
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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...

  14. #14
    wossname
    Guest
    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.

  15. #15
    New Member
    Join Date
    Jun 2002
    Location
    Spain
    Posts
    4
    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

  16. #16
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  17. #17
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I would if I could just remove you only...

  18. #18
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width