I think it's best to declare those as globals outside of the function.
So some rules for the OP:
Rule(1)
When declaring globals, use exact values, not system returned values which just won't work when declaring.
So instead of...
global iball = loadimage("crappyBall.png");
global ball = createSprite(iball);
Have...
global iball ball
iball = loadimage("crappyBall.png");
ball = createSprite(iball);
Rule(2)
Any variables that you need to affect inside a function, needs to be a global, or an array. So that Moveball function is using several variables which will all equal 0, because it is not keeping track due to those variables not being global - so globalize them as AL suggests, maybe be neater to make a type for them though... like this:
Type _entity
ID
x# y# xs# ys# dx# dy#
height width
Endtype
Then you can make your ball entity...
Global Ball as _entity
Then the type can be accessed with Ball.ID, Ball.x# etc etc - this can help keep code neat and well organized. If you globalize before the function, then you will be able to affect the variables as expected, like 'height as integer' would be 'Global height as integer' - then height could be used inside a function. When you need to have a lot of enemies, or a lot of bullets or coins to collect, then it's always best to use an array, which can use the same type as Ball. I advise looking into these type arrays before doing much else with your project. I think it makes best sense to work like this:
Dim Coin[64] as _entity
for c=0 to 63
Coin[c].ID=createsprite(img)
Coin[c].x#=random(0,512)
Coin[c].y#=random(0,512)
next c
That sorta thing.
I am the one who knocks...