PDA

View Full Version : Visual Basic



Tiffosi2000
05-03-2004, 11:45 AM
i am doing an assignment at the moment, i have done the following code in vb6. however when i try to run i get an error message;

compile error, variable required. cant assign to this expression.

here is my code;

Private Sub Command4_Click()

Dim costpaper As Single
Dim costpaint As Single
Dim costdoor As Single
Dim nodoors As Integer
Dim norooms As Integer
Dim w As Integer
Dim h As Integer
Dim l As Integer
Dim area13 As Integer
Dim area24 As Integer
Dim areaceiling As Integer
Dim arearoom As Integer
Dim totalarea As Integer
Dim roompainted As Integer
Dim roompapered As Integer
Dim totalcostpaint As Single
Dim totalcostpapered As Single
Dim totalcostdoors As Single
Dim subtotal As Single
Dim VAT As Single
Dim Total As Single

norooms = 1
costofpaint = 8
costofpaper = 7.5
costofdoor = 30

totalarea = 0
For Count = 0 To norooms
w = InputBox("Please Enter The Width Of The Room", "Width Of The Room")
h = InputBox("Please Enter The Height Of The Room", "Height Of The Room")
l = InputBox("Please Enter The Length Of The Room", "Length Of The Room")

area13 = 2 * (w * h)
area24 = 2 * (l * h)
areaceiling = w * l
arearoom = area13 + area24 + areaceiling
totalarea = totalarea + arearoom

endnext

- does anyone have any ideas?

i have checked the variables are listed. really stuck!!!

4th gen
05-03-2004, 11:55 AM
I've never used VB, so I'm probably way off, but does the "costofpaper" variable need to be stored differently, due to the fact it's a decimal?

Tiffosi2000
05-03-2004, 12:02 PM
thanks but its the actual 'for count' thats going wrong. something about the line

for count = 0 to norooms

i am cabbaged!!!