For my final project in my computer apps class we have to write a VBA program to dip a straw into a glass of water, remove the amount of water in the straw and repeat until the water level in the glass is 0.5 inches.
I'm getting overflow error 6 at the 5th line from the bottom and dont know why. This is the same code my instructor wrote during class and it worked for him.
[VBA]Dim Rs As Double
Dim iRow As Integer
Dim iCol As Integer
Dim nDips As Integer
Dim Cuph As Integer
Dim Rc As Double
Dim Volc As Integer
Dim Vols As Integer
Dim Hn As Integer
'Initial Straw Radius and column number
Rs = 0.2
iCol = 1
'Clear work area
Range("A1:K2000").Clear
'iterate through straw sizes
Do While Rs <= 0.5
'initialize data
nDips = 0
iRow = 2
Cuph = 10
Cells(1, iCol) = "Rs=" & Rs
'Column Reader
Cells(iRow, iCol) = "nDips"
Cells(iRow, iCol) = "Cup Height"
iRow = iRow + 1
'write initial values
Cells(iRow, iCol) = nDips
Cells(iRow, iCol) = Cuph
iRow = iRow + 1
'iterate til final cup height is established
Do While Cuph >= 0.5
'Calculate cup volume using cup radius and water level
'Calculate straw volume using straw radius and water level
'Get new cup volume after removing the water in the straw
'Calculate new water level
Cuph = Cuph - Rs
nDips = nDips + 1
Cells(iRow, iCol) = nDips
Cells(iRow, iCol) = Cuph
iRow = iRow + 1
Loop
iCol = iCol + 2
Rs = Rs + 0.05
Loop[/VBA]