0

I've been trying to create a program which displays every possible combination of letters, alongside some punctuation. It starts by running a single character through every letter, then it adds another character, and does the same thing, with each character only advancing when the previous one has run through every letter once again.

Naturally, I've encountered some issues. Whenever I'm testing it in the compiler, everything works fine. However, when I try and run the finished application, it only runs until some time around when the 3rd or 4th characters get added, at which point it stops responding. my code goes as follows:

    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
  • 3
    If your loop takes a long time, the UI doesn't have time to update itself (it can only do one thing at a time). You would need to execute your logic in a different thread. – the_lotus Jun 08 '18 at 16:36
  • Take a look at [Backgroundworker](https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx). The first example is similar to your application. – Tobbs Jun 08 '18 at 18:43

0 Answers0