Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aperture

macrumors 68000
Original poster
Mar 19, 2006
1,876
0
PA
I am desperately trying to convert numbers that I must use VB .NET (Obviously on Windows) to do and have no idea where/how to start. One "calculate" button will control all four conversions that will be run on the screen. A "reset" button will reset everything. Does anyone have any suggestions/tips on this? This is on VisualBasic .NET. Any help at all would be greatly appreciated. Below is what my final project must look like. (I have the front end of the app done, just not sure on the back code) Also, I need to have this done by Thursday and am clueless.:(

Thanks

VB-fin1.jpg


[Posted on behalf of brother (college, intro to programming course)]
 

Bubbasteve

macrumors 65816
Dec 23, 2004
1,163
0
Charleston, IL
How far are you on the form itself?

To accomplish the reset I would reset each of the txt boxes in the btnClick command....like so

txtBox1.text = ""
txtBox2.text = ""

and so on until you clear all of your text boxes or whatever you have them set as in VB.
I'm not really sure what you're asking in regards to the numbers...

A good start to it would be this...if I'm understanding you correctly

Dim CalcAcre as Single
Dim Arms-Length as Single

--- and so on until you have a dim for each conversion method....

txtBox1.text = "" -- to clear the text boxes... you may use names like txtAcre or something to easily differentiate between the different boxes

...so I would name them like txtAcre, txtPerch and so on....

and then I would put the equation for each is so

txtPerch.text = whatever the equation is to convert it....

and then just go down the line until you fill out all the conversions


I'm sorry that this description is really confusing but if you need me to elaborate on anything just quote me or something and I'll try to be more specific.

Good Luck!
 

Palad1

macrumors 6502a
Feb 24, 2004
647
0
London, UK
You didn't specify the order of conversion.. I'll assume we will convert from left to right but you may want to do it the other way around.

Or better yet do it both ways.

let's say your calculate button is called btCalculate



Code:
' just an event handler that will trigger the conversion
public sub btCalculate_OnClick(byval src as object,byval args as eventargs)
 doConversion()
end sub

' this one is the real conversion code. I did not place it in an event handler so we can share the code with a menu item or a textbox OnTextChanged event handler for example.
public sub doConversion()
 doArea() ' compute the area conversion
 doDistance() ' do the distance conversion
 doWeight() ' do the weight conversion
 doForce() ' do the force conversion
end sub

'Force conversion
public sub doForce()
 if(not tbKib.Text = string.Empty) then
  dim kip as decimal = Convert.ToDecimal(tbKib.Text)
  dim newtons as decimal = kip * 4448.221
 end if
end sub

' icing on the cake: automatic conversion
public sub tbKib_OnTextChanged(byval src as object, byval args as eventargs)
 doForce(); ' automagically convert when the text has changed.
end sub

ps: you made me type VB, you'll pay a dear cost for that... :D
 

Aperture

macrumors 68000
Original poster
Mar 19, 2006
1,876
0
PA
Hey Guys. I am still really confused, I got the "Clear" button working though.:) I posted the VB file online, if someone could PLEASE take a look at it, it would be GREATLY appreciated. If you make a change to it, you can email it to me at schaef2493@comcast.net. I need to have this done by tomorrow and I'm totally lost. Once again, ANY help is appreciated (& thanks to the guys who posted above, I am just really confused by the code) (Also, I'm not asking you to do it for me, all I need is an example of how the code would be implemented on one of the text boxes.

THANK YOU

Link to VB Project
 

Aperture

macrumors 68000
Original poster
Mar 19, 2006
1,876
0
PA
Bubbasteve, I got your email but it says my version of VB is not new enough to handle it. :mad: Anyway you could copy & paste all the code into <code> tags and then I can copy it into the project? Or, was there more changed then just the code? Thank you SO much for your help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.