Search code examples
vb.netnumberssequencegenerated

Generate sequence of numbers prefix with an alphabet


I would like to generate a sequence of numbers as "A0000"(ie.. an alphabet followed by 4numbers not randomly generated numbers).

I have gone through this article which is done with Sql Server similarly how can I achieve it in VB.Net.

Here is the code for SQL Server:

create function CustomerNumber (@id int) 
returns char(5) 
as 
begin 
return 'C' + right('0000' + convert(varchar(10), @id), 4) 
end

Any suggestions are welcome.


Solution

  • This should do the same:

    "C" & id.ToString("d4")
    

    Demo