Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

could some 1 plz help with VB code

  • 14-01-2002 11:03PM
    #1
    Registered Users, Registered Users 2 Posts: 3,312 ✭✭✭


    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, Registered Users 2 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, Registered Users 2 Posts: 3,312 ✭✭✭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, Registered Users 2 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