Hello,

I would like some help with the following. I try to develop myself in VBA code for my job.

I'm working on a program code that does calculation on 64 fields, for example an chessboard.
On field 1 lies 1 object, on field 2 lie 2 objects, on field 3 lie 4 objects and on field 4 lie 8 objects. So in total there are 15 objects on those 4 fields.

I want to write the program in such a way that I can beforehand type in an inputbox how many objects I have and how many fields can be filled with this number.

I've written the following code. Can you tell me which mistake I'm making?

-----------------------
Sub schaakbordv2()

'hoeveel graankorrels ter beschikking'"
'bereken hoeveel velden er gevuld kunnen worden'
'Het bestaat uit 64 velden: 8 horizontale rijen en 8'
'geef aantal korrels in msgbox'


Dim veldnr As Byte, aantalkorrels As Single, totaalkorrels As Single, teller As Integer

totaalkorrels = InputBox("hoeveel graankorrels heb je")

aantalkorrels = 1

For totaalkorrels = 1 To veldnr

aantalkorrels = 2 ^ veldnr

totaalkorrels = totaalkorrels + aantalkorrels
veldnr = veldnr + 1

Next totaalkorrels


MsgBox ("aantalvelden " & veldnr)

End Sub