I don't know where to begin. Before inserting the number, the btnCreate_Click procedure should alternate the case of each letter in the password. If the first character is lowercase, the procedure should change it to uppercase; it should then change the second letter to lowercase, the third letter to uppercase, and so on. For example, if the password is abcd, the procedure should change it to AbCd. On the other hand, if the first character is uppercase, the procedure should change it to lowercase and then alternate the case of the following letters. For example, if the password is Abcd, the procedure should change it to aBcD. Modify the procedure’s code. Here is my code.... Public Class frmMain Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click ' Create a password. Dim strWords As String Dim strPassword As String Dim intSpaceIndex As Integer strWords = txtWords.Text.Trim If strWords <> String.Empty Then ' Assign the first character as the password. strPassword = strWords(0) ' Search for the first space in the input. intSpaceIndex = strWords.IndexOf(" ") Do Until intSpaceIndex = -1 ' Concatenate the character that follows ' the space to the password. strPassword = strPassword & strWords(intSpaceIndex + 1) ' Search for the next space. intSpaceIndex = strWords.IndexOf(" ", intSpaceIndex + 1) Loop ' Insert the number after the first character. strPassword = strPassword.Insert(1, strPassword.Length.ToString) ' Display the final password. lblPassword.Text = strPassword End If End Sub Private Sub txtWords_Enter(sender As Object, e As EventArgs) Handles txtWords.Enter txtWords.SelectAll() End Sub Private Sub txtWords_TextChanged(sender As Object, e As EventArgs) Handles txtWords.TextChanged lblPassword.Text = String.Empty End Sub Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class
I don't know where to begin.
Before inserting the number, the btnCreate_Click procedure should alternate the case of each letter in the password. If the first character is lowercase, the procedure should change it to uppercase; it should then change the second letter to lowercase, the third letter to uppercase, and so on. For example, if the password is abcd, the procedure should change it to AbCd. On the other hand, if the first character is uppercase, the procedure should change it to lowercase and then alternate the case of the following letters. For example, if the password is Abcd, the procedure should change it to aBcD. Modify the procedure’s code.
Here is my code....
Public Class frmMain
Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
' Create a password.
Dim strWords As String
Dim strPassword As String
Dim intSpaceIndex As Integer
strWords = txtWords.Text.Trim
If strWords <> String.Empty Then
' Assign the first character as the password.
strPassword = strWords(0)
' Search for the first space in the input.
intSpaceIndex = strWords.IndexOf(" ")
Do Until intSpaceIndex = -1
' Concatenate the character that follows
' the space to the password.
strPassword = strPassword & strWords(intSpaceIndex + 1)
' Search for the next space.
intSpaceIndex = strWords.IndexOf(" ", intSpaceIndex + 1)
Loop
' Insert the number after the first character.
strPassword = strPassword.Insert(1, strPassword.Length.ToString)
' Display the final password.
lblPassword.Text = strPassword
End If
End Sub
Private Sub txtWords_Enter(sender As Object, e As EventArgs) Handles txtWords.Enter
txtWords.SelectAll()
End Sub
Private Sub txtWords_TextChanged(sender As Object, e As EventArgs) Handles txtWords.TextChanged
lblPassword.Text = String.Empty
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images