HELP I NEED TO GENERATE A RANDOM ID FOR MY EXAM...
NEED TO GET THE FIRST 3 LETTERS OF THE FIRST NAME....How do I do this?been searching for hours..
help greatly appreciated
HELP I NEED TO GENERATE A RANDOM ID FOR MY EXAM...
NEED TO GET THE FIRST 3 LETTERS OF THE FIRST NAME....How do I do this?been searching for hours..
help greatly appreciated
hello !
you can use substring() to perform this task , try this
txtTest.text = txtFirstName.text.Substring(0, 3).ToString
if you found this ans useful please mark this thread solved and vote me :P
Regards
for generating random number use random class for that. see below Example which gives you some idea how to generate Random Number.
Private Function GenerateRandomString(length As Integer) As String
Dim charPool As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Dim rs As New StringBuilder()
Dim rnd As New Random()
While System.Math.Max(System.Threading.Interlocked.Decrement(length),length + 1) > 0
rs.Append(charPool(CInt(rnd.NextDouble() * charPool.Length)))
End While
Return rs.ToString()
End Function
//call this function like this
txtTest.text = txtFirstName.text.Substring(0, 3).ToString &_ GenerateRandomString(3)
HELP I NEED TO GENERATE A RANDOM ID FOR MY EXAM...
NEED TO GET THE FIRST 3 LETTERS OF THE FIRST NAME....How do I do this?been searching for hours..
Just as simple as waqasaslammmeo explained!! Use Substring() method.
1st number inside brackets is starting index (in your case is 0, becuase you want to start from beginning)
2n number is th lenght if the string (3 in your case).
This is it.
Be sure to check the length of the string to make sure it's at least 3 characters (or whatever size of the substring).
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.