A switch basically lets all devices hooked to it access the same network. However, in order to successfully get on the internet you will need to have a router somewhere between your modem and the switch.
If you have a modem-router, then yes, the switch will work-- just hook it to the "LAN" side of the modem-router.
If you JUST have a modem (usually they only have a single LAN and a single WAN port), then you will need to get a router, which usually has a built-in 4port switch.