VB 脚本错误,我有代码 运行 这应该输出 2 位后缀,但有一个用户生成 3 位后缀

VB error in scripting, i have thi code running this should output 2 digit suffix but there is one user generates 3 digit suffix

While true
   i= i + 1
   Dim centralAccount As String = StringFormat("{0}{1:00}",accountPrefix, i)

这应该是输出:GH20(我从用户的名字和姓氏中得到 G 和 H)

但是至少有一个用户被创建为 GH200。可能是什么问题

用户输入他们的名字和姓氏,您想要return一个独特的帐户。此帐户将由用户的姓名首字母和数字 00 到 99 组成。

  1. 获取用户的首字母。
  2. 提供数字 00 t0 99
  3. 检查帐户是否唯一。

接下来我们有一个分支任务。该代码将执行 4 或 5

  1. 如果它是唯一的,我们就完成了。
  2. 如果它不是唯一的,请使用不同的号码重试。

第5步是循环的原因。我们不断尝试不同的号码,直到我们获得一个唯一的帐户或我们已经尝试了所有号码。

我们需要 Do 循环的计数器,这样当一组特定的首字母已经有帐户 00 到 99 时,我们就不会出现无限循环。在这种情况下,循环退出并且空字符串为 returned.

Private AccountList As New List(Of String)
Dim AcctNum As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim Account = GetCentralAccount(TextBox1.Text, TextBox2.Text)
    If Account = "" Then
        MessageBox.Show("There are no accounts available with your initials. Try your middle name.")
        Exit Sub
    End If
    MessageBox.Show($"Your Account is {Account}")
End Sub
Private Function GetCentralAccount(FirstName As String, LastName As String) As String
    'Step 1
    Dim accountPrefix = FirstName.First & LastName.First
    Dim Counter As Integer
    Do Until Counter = 99 'we have tried all the numbers with these initials and they are all taken
        'Create the new account
        Dim centralAccount = $"{accountPrefix}{AcctNum:00}"
        AcctNum += 1
        'Step 2
        'We don't want a number > 99. (two digits)
        If AcctNum > 99 Then
            AcctNum = 0
        End If
        'Step 3 We add each account to a list then we can check for uniqueness
        If Not AccountList.Contains(centralAccount) Then
            'Step 4.
            AccountList.Add(centralAccount)
            Return centralAccount
        End If
        Counter += 1
        'Step 5. We try again with a new account number
    Loop
    Return ""
End Function