vb.net应用程序在循环期间没有响应

时间:2018-06-08 16:16:33

标签: vb.net loops character do-while do-loops

我一直在尝试创建一个程序,显示每个可能的字母组合,以及一些标点符号。它首先在每个字母中运行一个字符,然后添加另一个字符,并执行相同的操作,每个字符只有在前一个字符再次遍历每个字母时才会前进。

当然,我遇到了一些问题。每当我在编译器中测试它时,一切正常。但是,当我尝试运行完成的应用程序时,它只运行到第3或第4个字符添加时的某个时间,此时它会停止响应。我的代码如下:

    Imports System.Windows.Forms

Public Class Form1
    Dim blnAutoAdvance As Boolean = False
    'Dim strOutputDisplay As String = ""
    Dim intTotChars As Integer = 57
    Dim intCharToWrite As Integer = 1 'the character to be written
    Dim intDigits As Integer = 0
    Dim finDisplay(1) As Char
    Dim intDigToWrite As Integer = 0
    Dim intTotDig As Integer = 1
    Dim intTotDigsave As Integer = 1
    Dim intCharToEdit As Integer = 1 ' chooses which char to edit

    Dim Character(32) As Char

    Dim AllCurrentChars(1) As Integer


    Private Sub btnScroll_Click(sender As Object, e As EventArgs) Handles btnScroll.Click
        Do
            finDisplay(intCharToEdit) = Character(intCharToWrite)
            Do While finDisplay(intCharToEdit) = "+"
                finDisplay(intCharToEdit) = "a"
                intCharToEdit = intCharToEdit + 1
                If intCharToEdit >= intTotDig Then
                    intTotDig = intCharToEdit
                    ReDim Preserve finDisplay(intTotChars)
                    ReDim Preserve AllCurrentChars(intTotChars)

                End If
                AllCurrentChars(intCharToEdit) += 1
                If AllCurrentChars(intCharToEdit) = 33 Then
                    AllCurrentChars(intCharToEdit) = 1
                End If
                finDisplay(intCharToEdit) = Character(AllCurrentChars(intCharToEdit))

            Loop
            intCharToEdit = 1
            lblDisplay.Text = finDisplay(intDigToWrite)
            intDigToWrite += 1
            Do
                lblDisplay.Text = lblDisplay.Text & finDisplay(intDigToWrite)
                intDigToWrite += 1
            Loop While intDigToWrite <= intTotDig
            intDigToWrite = 0
            intCharToWrite += 1
            If intCharToWrite = 33 Then
                intCharToWrite = 1
            End If
            Refresh()
        Loop
    End Sub


    Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Character(1) = "a"
        Character(2) = "b"
        Character(3) = "c"
        Character(4) = "d"
        Character(5) = "e"
        Character(6) = "f"
        Character(7) = "g"
        Character(8) = "h"
        Character(9) = "i"
        Character(10) = "j"
        Character(11) = "k"
        Character(12) = "l"
        Character(13) = "m"
        Character(14) = "n"
        Character(15) = "o"
        Character(16) = "p"
        Character(17) = "q"
        Character(18) = "r"
        Character(19) = "s"
        Character(20) = "t"
        Character(21) = "u"
        Character(22) = "v"
        Character(23) = "w"
        Character(24) = "x"
        Character(25) = "y"
        Character(26) = "z"
        Character(27) = " "
        Character(28) = "."
        Character(29) = ","
        Character(30) = "!"
        Character(31) = "?"
        Character(32) = "+"

    End Sub
End Class

0 个答案:

没有答案