GenerateRandom

Generates a random string, returns string passed, then full date, then 8-chars random string
Like in wetfile-2018-09-12-TGR45R4A

Public Function GenerateRandom(SystemText)
 Dim sb As New StringBuilder
 Dim r As New Random
 Dim idx As Integer
 Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
 Randomize()
 For i As Integer = 1 To 8
  Randomize()
  idx = r.Next(0, 35)
  sb.Append(s.Substring(idx, 1))
 Next
 Dim cSuffixName As String = Hex(CLng(Now.Ticks))
 Return SystemText & "-" & Format(Date.Today, "yyyy-MM-dd") & "-" & sb.ToString
End Function

SystemText

GenerateRandomFilename(&#34;wetfile&#34;)<br/>returns<br/>wetfile-2018-09-12-TGR45R4

Views 477 Downloads 200

'random', 'generate', 'password', 'string'

ANmarAmdeen
326
Texts + Strings VB.Net
Revisions

v1.0