Hi to all,
Hi I am developing entrance4u.com in which I want to generate exam number for each student. Let us take an example, It will like EFU001
. So for that I calculate total number of students, then I create String "EFU" , then I find out how many digit number I need to generate , suppose It's 3.(means SUM(Student) converted to string & calculate length)
Now my problem is How to Start with initial value 001 & not only 1
because I want my first number should be EFU001 & then EFU002,003...EFU100.

How to do that?

7 Years
Discussion Span
Last Post by serkan sendur

When you're generating your numbers use a SELECT CASE statement to decide which one of several string to append.
E.g. create the next number (i.e. 2) in a variable and check its length (1 in this case. Then use the select case to add the correct string to the front.
Example: (in VB.Net)
Dim student As Int
student = ' generate number by whatever means
Dim len As Int = student.Length()
Dim strNumber As String
Select Case len
Case 1
strNumber = "EFU00" & student 'for numbers 1-9
Case 2
strNumber = "EFU0" & student ' for numbers > 9
Case 3
strNumber = "EFU" & student ' for numbers > 99
End Select

Hope that helps, make as solved if so, thanks:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.