Vehicular Edge Computing (VEC) technology allows vehicles demanding significant computation and storage resources to offload their demands to the nearest edge computing node, aiming at reducing data transfer latency and enhancing the Quality of Service (QoS). Moreover, the heterogeneous applications of Vehicle-to-Everything (V2X) communications need an efficient management of the nodes' resources to satisfy the diverse requirements of the vehicles' demands. To this end, network slicing could be a promising solution. Task offloading algorithms in VEC proposed in the literature usually rely on offloading to a 5G base station (gNodeB) or a Road Side Unit (RSU) and do not differentiate between the various vehicular demands. In this paper, we study the task offloading problem with network slicing in V2X communications from vehicles to edge computing nodes hosted at gNodeBs, RSUs, and nearby vehicles. We model the network and formulate the problem as an integer linear program, with the objective of maximizing the volume of offloaded tasks from diverse services. We propose a heuristic algorithm and slicing schemes to find a near-optimal solution to the NP hard optimization problem. The simulation results show that considering offloading at nearby vehicles in addition to RSUs and gNodeBs yields better results in terms of acceptance ratio and resource utilization. Furthermore, it is found that it is beneficial to use an adaptive slicing scheme instead of relying on a fixed slicing; in particular, when the number of slices is large.