Part vector selection

Hello Guyss,

i need range out as variable from a and b but showing error please have look in it and provide solution.

module tb();
reg [5:0] a=5;
reg [5:0] b=10;
reg [20:0] out;

initial begin
out[b:a] = 7;
$monitor(out);
end

endmodule

not this solution
suppose i want to send byte by byte data
i can use a[i+:8]=b; it is working
but my case is i want to write 50 bytes some times 45 some times 33 its depend on user
then how i can write memory logic for this

That is completely new information. You have a memory (unpacked array), and you want to work in 8-bit bytes. It would help if you show us declarations for everything you are working with.