Do Until False
'左
If GetAsyncKeyState(37) <> 0 Then
x = x - 1
leftflg = True
rightflg = False
upflg = False
downflg = False
'左端のときはそれ以上左に行かない
If x < 1 Then
x = 1
End If
End If
'右
If GetAsyncKeyState(39) <> 0 Then
x = x + 1
rightflg = True
leftflg = False
upflg = False
downflg = False
'右端のときはそれ以上右に行かない
If x > 500 Then
x = 500
End If
End If