We investigate the vacuum expectation value (VEV) of the surface energy-momentum tensor for a charged scalar field in a higher dimensional locally anti-de Sitter spacetime with two parallel branes and with a compact dimension (generalized Randall–Sundrum model). The presence of a constant background gauge field is assumed. The latter gives rise to Aharonov-Bohm type effect on the characteristics of the scalar vacuum. The problem is reduced to the investigation of the VEV of the field squared on the branes. It is shown that the VEV can be decomposed into three contributions representing the VEV in the brane-free geometry, the VEV in a single brane geometry, and the contribution due to the second brane. The latter is investigated, and it is shown that this gives rise to a cosmological constant on the visible brane (our universe). The behavior of the cosmological constant is studied as a function of the locations of the branes, of the length of the compact dimension and of the magnetic flux enclosed by the compact dimension. In particular, it is shown that the cosmological constant is a periodic function of the magnetic flux with the period equal to the flux quantum. Depending on the parameters of the problem it can be either negative or positive.