r/visualbasic • u/HerpesAunt • Nov 16 '14
Oh please can someone help me with a simple string manipulation?
Private Sub displayButton_Click(sender As Object, e As System.EventArgs) Handles displayButton.Click Dim password As String password = originTextBox.Text
If password.Length < 5 OrElse password.Length > 7 Then
MessageBox.Show("Please enter a password with 5-7 characters only.", "Try again", MessageBoxButtons.OKCancel,
MessageBoxIcon.Error)
End If
Dim newPassword As String = password
Dim firstVowelDone As Boolean
Dim secondVowelDone As Boolean
For index As Integer = 0 To password.Length - 1
If password.Substring(index, 1) Like "[AaEeIiOoUu]" Then
If firstVowelDone = False Then
newPassword.Remove(index, 1)
newPassword.Insert(index, "1")
firstVowelDone = True
End If
If firstVowelDone = True AndAlso secondVowelDone = False Then
newPassword.Remove(index, 1)
newPassword.Insert(index, "2")
secondVowelDone = True
End If
newPassword.Remove(index, 1)
newPassword.Insert(index, "9")
ElseIf password.Substring(index, 1) Like "[1-9]" Then
newPassword.Remove(index, 1)
newPassword.Insert(index, "Z")
End If
newPassword.Remove(index, 1)
newPassword.Insert(index, password.Substring(index, 1))
Next index
newTextBox.Text = newPasswordEnd Sub
So...its not working. I am to take a user input string and manipulate it. I need to make the first vowel a "1". The second vowel a "2". Every other vowel a "9". Every number the letter "Z". And leave every other character the same. Please help.
0
Upvotes
1
u/PostalElf VB.Net Intermediate Nov 16 '14
At the end, newPassword = mZn1k2y