Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

could some 1 plz help with VB code

Options
  • 14-01-2002 11:03pm
    #1
    Registered Users Posts: 3,299 ✭✭✭


    could some one please comment this code or explain it a bit better. i would be very greatful if some one had the time to actualy rewrite the code in simpler i.e beginner language.THANX
    calculator


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I hope this isn't you homework ;)

    Anyway, first message I got was Must have start up form or sub main. Sub Main is a method that starts your program. Start up form means that a form load event starts your program. Go for Sub Main, it goes into a .bas file.

    I don't understand why you have a timer on the form, its displaying the last answer apparently but why a timer?

    Other than that it seems to be working fine.

    [hint]
    If I were to do the same project I'd use control arrays for the buttons and base their values on their array index. College Tutors would be impressed.
    [/hint]


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    dam i posted up the wrong code could some one have alook at this. how can u make a control array with the memory buttens and the /,*,-,+ buttensProper Calculator


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Right, the control array:

    for your number buttons create a button called cmdNumber. Give it a label of 0. Copy and then paste cmdNumber. You will be asked if you want to create a control array. Say yes, this will paste a new button called cmdNumber[1]. [1] being it's index, label this 1. Paste again, this will create a button called cmdNumber[2], label this 2. Your original button will have an index of 0. You're probably getting the idea now.

    this is how the events will appear in code:
    [COLOR=royalblue]Private Sub[/COLOR] cmdNumber_Click(Index [COLOR=royalblue]As Integer[/COLOR])
    
    End Sub
    

    There is only one method for all the buttons in the array. Index as Integer is the array index so if the user clicks 2 then the index will have a value of 2, click 8 then the index is valued 8. For the likes of equals and +/-. Well try and work something out and come back if you get stuck, I'd use a different array for these though.

    Hope this helps, I've only tried to start you off here as you'll learn a lot more if you work it out for yourself.


Advertisement