Sign in with
Sign up | Sign in
Your question

Visual Basic - Need Some Help

Last response: in Applications
Share
July 18, 2009 12:55:09 AM

Just started doing some VB again after about a year and a half. I'm making a calculator with a pretty specific purpose. I know how to make the program with buttons, but I can't seem to remember how you go about having things automatically calculate as you enter values, or if that's even possible in VB. Any info? Thanks.

More about : visual basic

a b L Programming
July 18, 2009 1:11:11 AM

Haven't programmed VB in a while, but exactly what would you want to automatically calculate? What you are looking might be some kind of "onKeyPress" or "onValueChange" events, but unless you give me an example there isn't more I can tell.
July 18, 2009 1:22:58 AM

Zenthar said:
Haven't programmed VB in a while, but exactly what would you want to automatically calculate? What you are looking might be some kind of "onKeyPress" or "onValueChange" events, but unless you give me an example there isn't more I can tell.


It's used for calculating the needed port length in subwoofer boxes.



I'm not 100% sure about how to go about doing this, to be quite honest. The first part is easy;
(Length - (2* Wood Thickness)) * (Width - (2* Wood Thickness)) * (Height - (2* Wood Thickness)) / 1728
But after that I want it to display the value given from that in the Gross Volume text box. After that there has to be some crazy math done, but I have all the equations typed out already.
Related resources
July 18, 2009 3:42:36 AM

I have and own a license of Microsoft Visual Studio 2008 Professional Edition, it has all the different microsoft developer programs like VB, web developer, c#,C++...etc all in one package and i could do a little bit of everything so cant really help you in specifics, however what I do know is that microsoft has an excellent massive forum called MSDN specifically for microsoft products like visual studio and all those developer programs and stuff and you can get much more help there, replies, and better assistance. Any question you have, that forum can help.
July 18, 2009 3:52:41 AM

blackhawk1928 said:
I have and own a license of Microsoft Visual Studio 2008 Professional Edition, it has all the different microsoft developer programs like VB, web developer, c#,C++...etc all in one package and i could do a little bit of everything so cant really help you in specifics, however what I do know is that microsoft has an excellent massive forum called MSDN specifically for microsoft products like visual studio and all those developer programs and stuff and you can get much more help there, replies, and better assistance. Any question you have, that forum can help.


Yeah, I got a license for VS2008 Pro from my tech teacher :D  I'll go check out that forum. Thank you very much!
July 19, 2009 6:17:10 AM

Alright, well I decided to just go with a button for now just so that I could get it working and go from there. I got all my code written (took long enough...), and it compiles fine. But when I go to calculate, I get one error, and I have no clue what it means.



Not quite sure what that means. Can supply code if needed.
a b L Programming
July 19, 2009 12:17:16 PM

This error seems to be caused by VB trying to convert an empty textbox value ("") to a double value. You might have to explicitly detect empty textbox and replace their value with some default one (ex: 0).

As for calculating "on the fly", the event you are looking for is either KeyPress to really calculate as the user type or FocusLost if you want the calculation to occur when the user leaves the field.
July 19, 2009 6:57:57 PM

Zenthar said:
This error seems to be caused by VB trying to convert an empty textbox value ("") to a double value. You might have to explicitly detect empty textbox and replace their value with some default one (ex: 0).

As for calculating "on the fly", the event you are looking for is either KeyPress to really calculate as the user type or FocusLost if you want the calculation to occur when the user leaves the field.


Thank you for your reply. As for the error, I have resolved that issue.

For the calculating on the fly, I'll look into using one of those methods on the next version I make. Thank you very much!
!