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?

Recommended Answers

All 2 Replies

Hi,
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:)

>make as solved if so, thanks
you got our conventions although being a light 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.