|
-
Jan 4th, 2011, 05:11 PM
#1
Thread Starter
Junior Member
Re: Random number generator - select concatentation method
 Originally Posted by MarMan
Interrogate the random number and call the appropriate function.
Code:
Select Case Int(rnd(1)* NumberOfFunctions ) + 1
Case 1
CallMethod1
Case 2
CallMethod2
ect.
End Select
Hi there, thanks for you reply, I am now getting a sub or function not defiended error :s. My code is as follows:
Code:
Private Sub create_user_answer(ByRef whole_user_answer)
whole_user_answer = user_answer_4 & user_answer_3 & user_answer_2 & user_answer_1
End Sub
Private Sub Form_Load()
'This sets the interval for for the specified Timer(Print_Heading) equal to 63ms
Print_Message.Interval = 63
'This enables the specified Timer(Print_Heading)
Print_Message.Enabled = True
End Sub
Private Sub Option1_Click()
MsgBox "Are you sure you wish to generate 2 passwords?"
End Sub
Private Sub Option2_Click()
MsgBox "Are you sure you wish to generate 3 passwords?"
End Sub
Private Sub Option3_Click()
MsgBox "Are you sure you wish to generate 4 passwords?"
End Sub
Private Sub Option4_Click()
MsgBox "Are you sure you want to generate passwords that are long in length?"
End Sub
Private Sub Option5_Click()
MsgBox "Are you sure you want to generate passwords that are medium length?"
End Sub
Private Sub Option6_Click()
create_short_passwords whole_user_answer
MsgBox "Are you sure you want to generate passwords that are short in length?"
End Sub
Private Sub Print_Message_Timer()
'This declares the text which shall be displayed one character after another:
title_text_string = "Please select how many passwords you wish to generate:"
Static Ptr As Long
If Ptr < Len(title_text_string) Then
Ptr = Ptr + 1
lbl_intro.Caption = Left$(title_text_string, Ptr)
Else
Ptr = 0
'This disables the specified Timer(Print_Heading)
Print_Message.Enabled = False
'This ends the IF statement
End If
End Sub
Private Sub create_short_passwords(ByVal whole_user_answer)
Select Case Int(Rnd(1) * 5) + 1
Case 1
Call concatentation_method_1
Case 2
Call concatentation_method_2
Case 3
Call concatentation_method_3
Case4
Call concatentation_method_4
Case5
Call concatentation_method_5
End Select
Dim concatentation_method_1 As String
Dim concatentation_method_2 As String
Dim concatentation_method_3 As String
Dim concatentation_method_4 As String
Dim concatentation_method_5 As String
concatentation_method_1 = Left$(whole_user_answer, 3) & Right$(whole_user_answer, 3)
concatentation_method_2 = Left$(whole_user_answer, 2) & Right$(whole_user_answer, 3)
concatentation_method_3 = Left$(whole_user_answer, 3) & Right$(whole_user_answer, 2)
concatentation_method_4 = Left$(whole_user_answer, 2) & Right$(whole_user_answer, 2)
concatentation_method_5 = Left$(whole_user_answer, 1) & Right$(whole_user_answer, 3)
MsgBox selectcase
End Sub
'I have only implemented it into Private Sub create_short_passwords
Many thanks,
-
Jan 5th, 2011, 01:07 AM
#2
Re: Random number generator - select concatentation method
You call a Sub named "concatentation_method_1" which doesn't exist, instead you declared "concatentation_method_1" as String!
At last you try to display "Select Case", which can't show you anything since its a function.
What do you try to do with a selected "concatention_method_?"?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 5th, 2011, 10:00 AM
#3
Thread Starter
Junior Member
Re: Random number generator - select concatentation method
 Originally Posted by opus
You call a Sub named "concatentation_method_1" which doesn't exist, instead you declared "concatentation_method_1" as String!
At last you try to display "Select Case", which can't show you anything since its a function.
What do you try to do with a selected "concatention_method_?"?
Ok, thanks.
There may be some ambiguity in my question. I do not want each concatentation method to be a different sub. I want each password sub to have the ability to randomise the concatentation methods within that password sub as not all concatentation methods are the same for creating short, medium, and long passwords.
Is there anyway of randomising the concatentation methods within each password sub so that not the same concatentation methods are chosen each time each individual procedure is activated?
Code:
Private Sub Command1_Click()
create_user_answer whole_user_answer
End Sub
Private Sub create_user_answer (ByRef whole_user_answer)
whole_user_answer = user_answer_4 & user_answer_3 & user_answer_2 & user_answer_1
MsgBox whole_user_answer
End Sub
Private Sub Option4_Click()
create_long_passwords whole_user_answer
MsgBox "Are you sure you want to generate passwords that are long in length?"
End Sub
Private Sub Option5_Click()
create_medium_passwords whole_user_answer
MsgBox "Are you sure you want to generate passwords that are medium length?"
End Sub
Private Sub Option6_Click()
create_short_passwords whole_user_answer
MsgBox "Are you sure you want to generate passwords that are short in length?"
End Sub
Private Sub create_short_passwords(ByVal whole_user_answer)
'I want the concatentaion methods in this sub to be randomised
Dim concatentation_method_1 As String
Dim concatentation_method_2 As String
Dim concatentation_method_3 As String
Dim concatentation_method_4 As String
Dim concatentation_method_5 As String
concatentation_method_1 = Left$(whole_user_answer, 3) & Right$(whole_user_answer, 3)
concatentation_method_2 = Left$(whole_user_answer, 2) & Right$(whole_user_answer, 3)
concatentation_method_3 = Left$(whole_user_answer, 3) & Right$(whole_user_answer, 2)
concatentation_method_4 = Left$(whole_user_answer, 2) & Right$(whole_user_answer, 2)
concatentation_method_5 = Left$(whole_user_answer, 1) & Right$(whole_user_answer, 3)
MsgBox selectcase
End Sub
Private Sub create_medium_passwords(ByVal whole_user_answer)
'I want the concatentaion methods in this sub to be randomised
Dim concatentation_method_1 As String
Dim concatentation_method_2 As String
Dim concatentation_method_3 As String
Dim concatentation_method_4 As String
Dim concatentation_method_5 As String
concatentation_method_1 = Left$(whole_user_answer, 4) & Right$(whole_user_answer, 4)
concatentation_method_2 = Left$(whole_user_answer, 3) & Right$(whole_user_answer, 4)
concatentation_method_3 = Left$(whole_user_answer, 4) & Right$(whole_user_answer, 3)
concatentation_method_4 = Left$(whole_user_answer, 2) & Right$(whole_user_answer, 5)
concatentation_method_5 = Left$(whole_user_answer, 5) & Right$(whole_user_answer, 3)
End Sub
Private Sub create_long_passwords(ByVal whole_user_answer)
'I want the concatentaion methods in this sub to be randomised
Dim concatentation_method_1 As String
Dim concatentation_method_2 As String
Dim concatentation_method_3 As String
Dim concatentation_method_4 As String
Dim concatentation_method_5 As String
concatentation_method_1 = Left$(whole_user_answer, 5) & Right$(whole_user_answer, 4)
concatentation_method_2 = Left$(whole_user_answer, 4) & Right$(whole_user_answer, 5)
concatentation_method_3 = Left$(whole_user_answer, 5) & Right$(whole_user_answer, 5)
concatentation_method_4 = Left$(whole_user_answer, 6) & Right$(whole_user_answer, 5)
concatentation_method_5 = Left$(whole_user_answer, 5) & Right$(whole_user_answer, 6)
End Sub
'note how each concatentation method is different in each create_password sub(short,medium, long)
Many thanks,
Bainy
-
Jan 5th, 2011, 10:28 AM
#4
Re: Random number generator - select concatentation method
Yes there is. Use the SELECT CASE statement.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|