Re: VBA calculator problems

Posted 12 May 2009 - 11:32 PM

You are trying to use variables that are set in another procedure. You must 'pass' the variable to the using procedure or declare it as public. Since this code is behind a form, declare public variables in the form's code header area. Variables 'Sign' and 'a' fit this situation. Use step debugging to follow the code execution. The code will stop after each line of code is executed. You can put breakpoints where you think the problem is and code will run until the breakpoint is encountered and then will be in step mode. This allows you to see what values the variables hold. Just hover the cursor over them. Suggest you do this with each click event. You will get a better understanding of how your program works.

Edit: You identify this as VBA, are you in an Access project? Scratch question, your code looks like VB.Net

In VBA for Accesss would declare these variables with the Dim statement as described in post above in header section of form. May be somewhat different in VB.Net. But must be declared as public so that all the click procedures manipulating them can get the value set in other procedures. Is this clearer now?

Re: VBA calculator problems

Posted 13 May 2009 - 03:27 PM

In what way is it not working now. Have you step debugged? Declaring 'Sign' in each procedure won't work. It and 'a' have to be declared in public area, as I said, for Access that would be the header of the code behind the form. I don't use VB.Net but gleaned from book would be in a module or form class, something like:

Public Class Form1
Public Sign As String
Public a As String
'continue with code for your form controls
End Class

Re: VBA calculator problems

Posted 13 May 2009 - 03:31 PM

June7, on 13 May, 2009 - 02:27 PM, said:

In what way is it not working now. Have you step debugged? Declaring 'Sign' in each procedure won't work. It and 'a' have to be declared in public area, as I said, for Access that would be the header of the code behind the form. I don't use VB.Net but gleaned from book would be in a module or form class, something like:

Public Class Form1
Public Sign As String
'continue with code for your form controls
End Class

I'm not using vb.net. It won't work meaning nothing happens when i hit the equals button. Could you please explain step debugging?

Re: VBA calculator problems

Posted 13 May 2009 - 03:52 PM

Still trying to determine what application you are working in. You said VBA code, that would mean Access, Excel, or Word. In Access to get the info entered into a text box would use .Value instead of .Text. Is 'screen' a text box?

Re: VBA calculator problems

Posted 13 May 2009 - 03:54 PM

June7, on 13 May, 2009 - 02:52 PM, said:

Still trying to determine what application you are working in. You said VBA code, that would mean Access, Excel, or Word. In Access to get the info entered into a text box would use .Value instead of .Text. Is 'screen' a text box?