unna456654
18.02.2009, 16:02
Hi leute,
habe hier folgende Klasse aus dem Netz geholt:
Public Class SerialNumber
Private m_BlockLength As Int64 = 6
Private m_BlockCount As Int64 = 2
Private m_Delimiter As String = "-"
Public Sub New()
End Sub
Public Sub New(ByVal BlockLength As Int64, ByVal BlockCount As Int64)
m_BlockLength = BlockLength
m_BlockCount = BlockCount
End Sub
Public Sub New(ByVal BlockLength As Int64, ByVal BlockCount As Int64, _
ByVal Delimiter As String)
m_BlockLength = BlockLength
m_BlockCount = BlockCount
m_Delimiter = Delimiter
End Sub
Private Function Generate(ByVal BlockLength As Int64, _
ByVal BlockCount As Int64, ByVal Delimiter As String) As String
Dim si As New StringBuilder
Dim sb As New StringBuilder
For n As Int16 = 0 To BlockCount - 1
Try
si.Append(Guid.NewGuid.ToString().Replace("-", "").ToUpper)
sb.Append(si.ToString.Substring(n * BlockLength, BlockLength) & Delimiter)
Catch ex As Exception
Throw New Exception("Err0r")
End Try
Next
Return sb.ToString.Substring(0, sb.Length - Delimiter.Length)
End Function
Public Overrides Function ToString() As String
Return Me.Generate(m_BlockLength, m_BlockCount, m_Delimiter)
End Function
End ClassLeider gibt sie Buchstaben UND Zahlen aus.
ist es möglich nur Buchstaben zu erhalten? Wenn ja wie?[/quote]
habe hier folgende Klasse aus dem Netz geholt:
Public Class SerialNumber
Private m_BlockLength As Int64 = 6
Private m_BlockCount As Int64 = 2
Private m_Delimiter As String = "-"
Public Sub New()
End Sub
Public Sub New(ByVal BlockLength As Int64, ByVal BlockCount As Int64)
m_BlockLength = BlockLength
m_BlockCount = BlockCount
End Sub
Public Sub New(ByVal BlockLength As Int64, ByVal BlockCount As Int64, _
ByVal Delimiter As String)
m_BlockLength = BlockLength
m_BlockCount = BlockCount
m_Delimiter = Delimiter
End Sub
Private Function Generate(ByVal BlockLength As Int64, _
ByVal BlockCount As Int64, ByVal Delimiter As String) As String
Dim si As New StringBuilder
Dim sb As New StringBuilder
For n As Int16 = 0 To BlockCount - 1
Try
si.Append(Guid.NewGuid.ToString().Replace("-", "").ToUpper)
sb.Append(si.ToString.Substring(n * BlockLength, BlockLength) & Delimiter)
Catch ex As Exception
Throw New Exception("Err0r")
End Try
Next
Return sb.ToString.Substring(0, sb.Length - Delimiter.Length)
End Function
Public Overrides Function ToString() As String
Return Me.Generate(m_BlockLength, m_BlockCount, m_Delimiter)
End Function
End ClassLeider gibt sie Buchstaben UND Zahlen aus.
ist es möglich nur Buchstaben zu erhalten? Wenn ja wie?[/quote]