Click here to Skip to main content
15,799,257 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
Hello !!

I am learning vb.net 2013

i have a doubt

i have two textboxes, textbox1 and textbox2

the value name entered in textbox1 should be displayed in the reverse in textbox2

for example

textbox1= Water

textbox2= retaw

now when i click the button

the value in textbox2 should in the below method in a combobox

r

e

t

a

w

can someone please guide me through the coding to display the entered name in the above format in combobox

Thanks in advance !!

What I have tried:

I tried the first part, reverse of the entered text is done
i want the solution for the second part
i want to know how to display the reversed text in the combobox
Posted
Updated 4-Jun-17 4:15am

Easy:
C#
private void tbUserInput_TextChanged(object sender, EventArgs e)
    {
    tbReversed.Text = new string(tbUserInput.Text.Reverse().ToArray());
    }

private void tbReversed_TextChanged(object sender, EventArgs e)
    {
    cbReversedItems.Items.Clear();
    foreach (char c in tbReversed.Text)
        {
        cbReversedItems.Items.Add(c);
        }
    }
 
Share this answer
 
Dim vowels As String = "aeiou"
Dim alphabet As String = "abcdefghijklmnopqrstuvwxyz"

If vowels.Contains(ComboBox1.Text) Then
    TextBox1.Text = alphabet
End If
 
Share this answer
 
Comments
Member 13239658 4-Jun-17 8:39am    
this works perfectly fine. thanks a lot
but one last question
if there are two or three vowels in a name
how do i display all the vowels seperating it by a comma
like when i select one vowel it should be dispalyed in the textbox and when i select one more vowel a comma should seperate and the other vowel also should be displayed

both should be displayed
[no name] 4-Jun-17 9:15am    
Dim nameWithThreeVowels As String = "aeiouxyz"

Dim numberOfVowels As Integer = 0
Dim vowelsFound As String = ""

' loop through each character 'c'
For cIndex As Integer = 0 To nameWithThreeVowels.Length - 1
Dim c As String = nameWithThreeVowels(cIndex) 'get the letter at the specified position
If vowels.Contains(c) Then
numberOfVowels +=1

vowelsFound &= c & ","
End If
Next

' remove the last comma so you don't end up with '1,2,3,' for example
If Not vowelsFound = "" Then
vowelsFound = vowelsFound.Substring(0, vowelsFound.Length - 2)
End If

If numberOfVowels = 3 Then
MsgBox("3 vowels found: " & vowelsFound)
End If


Dim nameWithThreeVowels As String = "aeixyz"

Dim numberOfVowels As Integer = 0
Dim vowelsFound As String = ""

' loop through each character 'c'
For cIndex As Integer = 0 To nameWithThreeVowels.Length - 1
    Dim c As String = nameWithThreeVowels(cIndex) 'get the letter at the specified position
    If vowels.Contains(c) Then
        numberOfVowels +=1
        
        vowelsFound &= c & ","
    End If
Next

' remove the last comma so you don't end up with '1,2,3,' for example
If Not vowelsFound = "" Then
    vowelsFound = vowelsFound.Substring(0, vowelsFound.Length - 2)
End If

If numberOfVowels = 3 Then
    MsgBox("3 vowels found: " & vowelsFound)
End If
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900