2015年8月4日星期二

Excel VBA code animator


Research in computer science education suggests that students need a good mental model of computers. A program simulator helps them develop that model.
This page shows an Excel VBA simulator written in JavaScript. While the program is running, you can change the instruction pointer, memory, and spreadsheet cells. This might cause the VBA program to crash, of course. That's intentional. Being able to create, for example, a data type mismatch error will help students understand how VBA works, and what problems to expect in their projects.
This is the first version of the simulator. It will be improved over time.
Spreadsheet You can change any of the cells.
ABCD
1
2
3
4
5
6
CPU The CPU runs the program, and does all the calculations.
Run status
RunningWhether the CPU is running a program or not.
Next line
Next line of the program to be run.

You can change it.
Evaluator
(Empty)Where the CPU does calculations.
What just happened
Program The code someone typed.
  1. Dim aLongVariableName as String
  2. aLongVariableName = "dog"
  3. Dim i as Integer
  4. Dim j as Integer
  5. j = InputBox("How many?")
  6. Dim k as Integer
  7. i = Cells(1,2) - j
  8. k = Cells(2,2)
  9. If i < 0 Then
  10.   i = k
  11. Else
  12.   i = k * 2
  13. EndIf
  14. Cells(2, 2) = i
  15. MsgBox "Number: " & (j + 2)
  16. 'That's all.
Memory Where variables are created. You can change their values.
 

没有评论:

发表评论