首先请看一下附件项目,以便更好地理解。
您可以下载项目并试玩,尽管它无法按预期工作 我正在尝试编写一个应用程序,该应用程序将在窗体的列表框中打印所有关键的无聊概率,以便在将其导入数据库后可以进行。
应用程序将首先询问用户您的概率变量的长度是多少。
例如,用户将在表格的文本框中写入8个字符。 之后,用户将单击“计算”按钮,一旦他单击它 考虑到计算用户在上面编写的8个字符的概率,它将生成所有关键无聊字母的概率(26个大写字母,26个小写字母,10位数字和13个符号)。 。
我知道这可能会泄漏进程并冻结CPU, 我正在寻找实现这一目标的正确方法,如果有一个进度条加载器指示该过程的持续时间,那将是很好的。
任何建议将不胜感激
这是我当前的代码:
Private Function AnyTextBoxEmpty() As Boolean
AnyTextBoxEmpty = Text1.Text = ""
End Function
Private Sub Command5_Click()
Form1.Refresh
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = Rnd * 300 + 10
ProgressBar1.Value = ProgressBar1.Value + 2
loader.Caption = ProgressBar1.Value & "%"
If loader.Caption = 100 & "%" Then
MsgBox ("Probabilities have been generated successfully")
End If
End Sub
Private Sub Command2_Click()
Dim i As Long
Dim x As Long
i = 1
If AnyTextBoxEmpty Then
MsgBox ("You need to write the length of your password")
Text1.Text = ""
Text1.SetFocus
Else
Dim CapitalLetter As String
CapitalLetter = "A"
x = Text1.Text
ProgressBar1.Value = i + 1
loader.Caption = ProgressBar1.Value & "%"
If Text1.Text = Text1.Text Then
loader.Caption = 100 & "%"
MsgBox ("Probabilities have been generated successfully")
End If
End If
Do While (i <= x)
List1.AddItem (i & CapitalLetter) + CapitalLetter
i = i + 1
Loop
End Sub
Private Sub Form_Load()
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
If Text4.Text = "" Then
Text4.BackColor = &H80000003
Else
Text4.BackColor = &HC0FFFF
End If
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text1_Click()
Text1.BackColor = &HC0FFFF
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text2_Click()
Text2.BackColor = &HC0FFFF
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text2_Change()
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text3_Click()
Text3.BackColor = &HC0FFFF
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text3_Change()
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text4_Click()
Text4.BackColor = &HC0FFFF
If Text4.Text = "" Then
Text4.BackColor = &H80000003
Else
Text4.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text5_Change()
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text5_Click()
Text5.BackColor = &HC0FFFF
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text6_Change()
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text6_Click()
Text6.BackColor = &HC0FFFF
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
Private Function AnyTextBoxEmpty() As Boolean
AnyTextBoxEmpty = Text1.Text = ""
End Function
Private Sub Command5_Click()
Form1.Refresh
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = Rnd * 300 + 10
ProgressBar1.Value = ProgressBar1.Value + 2
loader.Caption = ProgressBar1.Value & "%"
If loader.Caption = 100 & "%" Then
MsgBox ("Probabilities have been generated successfully")
End If
End Sub
Private Sub Command2_Click()
Dim i As Long
Dim x As Long
i = 1
If AnyTextBoxEmpty Then
MsgBox ("You need to write the length of your password")
Text1.Text = ""
Text1.SetFocus
Else
Dim CapitalLetter As String
CapitalLetter = "A"
x = Text1.Text
ProgressBar1.Value = i + 1
loader.Caption = ProgressBar1.Value & "%"
If Text1.Text = Text1.Text Then
loader.Caption = 100 & "%"
MsgBox ("Probabilities have been generated successfully")
End If
End If
Do While (i <= x)
List1.AddItem (i & CapitalLetter) + CapitalLetter
i = i + 1
Loop
End Sub
Private Sub Form_Load()
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
If Text4.Text = "" Then
Text4.BackColor = &H80000003
Else
Text4.BackColor = &HC0FFFF
End If
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text1_Click()
Text1.BackColor = &HC0FFFF
If Text1.Text = "" Then
Text1.BackColor = &H80000003
Else
Text1.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text2_Click()
Text2.BackColor = &HC0FFFF
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text2_Change()
If Text2.Text = "" Then
Text2.BackColor = &H80000003
Else
Text2.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text3_Click()
Text3.BackColor = &HC0FFFF
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text3_Change()
If Text3.Text = "" Then
Text3.BackColor = &H80000003
Else
Text3.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text4_Click()
Text4.BackColor = &HC0FFFF
If Text4.Text = "" Then
Text4.BackColor = &H80000003
Else
Text4.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text5_Change()
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text5_Click()
Text5.BackColor = &HC0FFFF
If Text5.Text = "" Then
Text5.BackColor = &H80000003
Else
Text5.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text6_Change()
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
Private Sub Text6_Click()
Text6.BackColor = &HC0FFFF
If Text6.Text = "" Then
Text6.BackColor = &H80000003
Else
Text6.BackColor = &HC0FFFF
End If
End Sub
谢谢