Hi guys I need help from you. How do i increment the id like for example: EMP001, EMP002, EMP003 I hope you can help me out guys, thanks in advanced.
Gilbert_3 0
Newbie Poster
Recommended Answers
Jump to PostTry
Private Function NextID(empid As String) As String Dim n As Integer = CInt(empid.Substring(3)) Return empid.Substring(0, 3) & Format(n + 1, "000") End Function
Test with
MsgBox(NextID("EMP013"))
Jump to PostYou have to pass it the current max id and it will return the next one.
Jump to PostFirst of all, you should have specified that this is (probably) a database question, plus, what type of database. You can't autoincrement a string field. You'd have to specify empid as a numeric (int). if you want to use
EMP###
as the format then you can calculate that on …
All 10 Replies
Reverend Jim 4,780
Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Gilbert_3 0
Newbie Poster
Reverend Jim 4,780
Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Gilbert_3 0
Newbie Poster
Reverend Jim 4,780
Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Gilbert_3 0
Newbie Poster
Gilbert_3 0
Newbie Poster
Reverend Jim 4,780
Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Gilbert_3 0
Newbie Poster
Reverend Jim 4,780
Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.