レベルの低い事聞いて申し訳ないのですが,フォームの右端にきたら、左方向へ移動。
フォームの左端にきたら右方向へ移動しなさいという問題なのですが,
Dim ax As Integer

Private Sub Form_Load()
ax = 100
End Sub

Private Sub Timer1_Timer()
Image1.Left = Image1.Left + ax
If Image1.Left >= Form1.ScaleWidth - Image1.Width Or Image1.Left <=0 Then
ax = -ax
End If
End Sub
では、うまくいくのですが、

Private Sub Timer1_Timer()
dim ax as integer
ax = 100
Image1.Left = Image1.Left + ax
If Image1.Left >= Form1.ScaleWidth - Image1.Width Or Image1.Left < 0 Then
ax = -ax
End If
End Sub
だとうまくいきません。これはなぜですか?タイマーイベントだと宣言はgeneral declarationsでしなければならい
とか、この場合axなどの初期値はform loadに書かなければならないという決まりがあるのでしょうか?