This is Visual Basic (VB.net) Problem. Create a Password generator application a
ID: 3695102 • Letter: T
Question
This is Visual Basic (VB.net) Problem.
Create a Password generator application as shown below.
As usual, make sure the code is properly documented with top level comments at a minimum, and ensure all conversions are explicit.
The user enters how many characters the password must be made of, then clicks a Generate button.
The output is then a string made of numbers, letters (some of are upper case and some are lower case) along with any other characters you wish to use.
The code must use a For loop and no other type of loop.
The code must also use the Chr string functions, along with the Random function.
The Random function generates a number (you need to figure out the range).
The number generated in then used in the Chr function as the ASCII value to generate a character.
The code must randomize using a letter, upper case or lower case, a number or some other characters.
Note there will be two random numbers created: one to decide whether to generate a number, lowercase or upper case character. The second random number is used to create the actual character in the randomly selected category.
Explanation / Answer
public Class Form1
private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim n, n1 As Integer
dim Generator As System.Random = New System.Random()
dim s As String
s = ""
n = Val(TextBox1.Text)
for i = 1 To n
n1 = Generator.Next(1, 128)
s = s & Chr(n1)
next
TextBox2.Text = s
end Sub
end Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.