Hello, I'm re-reading my notes from my programming class last week and I need help coming up with a line. We're using Visual Basic in class and we were just messing around with some stuff. The task i'm trying to do is figure out how to calculate the area of a room but I can't figure out what how to write that code. I know it's length * width I have it set up to where you write the input into the length and width box, then you press the button to calculate the output into a separate text box. Any suggestions? thanks in advance
oh hehe I got it Dim area As Double Dim length As Double Dim width As Double length = CDbl(txtLength.Text) width = CDbl(txtWidth.Text) area = length * width txtArea.Text = CStr(area) A mod can delete the thread haha
OMG, this is easy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! iris is right but I would change the last line to this: txtArea.Text =math.round( CStr(area)*100) *100 it rounds to 2 decimal places.
mmm... i think that jonathan is wrong... cause if u just want to round it to 2 decimal... just Try TxtArea.Text= CStr(Round(area , 2)); that would be enough to do the trick
I made a mistake. It's suppose to be: txtArea.Text =math.round( CStr(area)*100) /100 How come you need to convert it to String. Area is a double, not a word. (Just wondering) TxtArea.Text= CStr(Round(area , 2))
Well, the above is true if you compile with option explicit. If not, the textbox.text will convert the values to String.