Couldn't you do the same logic but just consider the total speed?
if distance(0, 0, vx, vy) > maxspeed
{
//do nothing
}
else if distance(0, 0, vx+ax, vy+ay) > maxspeed
{
ang = angle(0, 0, vx+ax, vy+ay)
vx = maxspeed*cos(ang)
vy = maxspeed*sin(ang)
}
else
{
vx += ax
vy += ay
}