Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys i really need help with my visual basic capstone project. i started it

ID: 3587840 • Letter: H

Question

Hey guys i really need help with my visual basic capstone project. i started it but its not working so i need someone to help me complete it.

its called a basic Alphabetizer. its supposed to alphabetize words. Here is my code and form i made. Please add comments to my code

please if you cant make it work dont waste my question . thank you.

Public Class Form1
Private Sub btnSort_Click(sender As Object, e As EventArgs) Handles btnSort.Click
Dim Str1, Str2 As String
Dim strWords(19) As String
Dim Flag1 As Integer
For index = 0 To 19
strWords(index) = InputBox("enter some words")
lstWords.Items.Add(strWords(index))
Next
Do
Flag1 = 0
For i = 0 To 19
Str1 = strWords(i)
Str2 = strWords(i + 1)
If Asc(strWords(i)) > Asc(strWords(i + 1)) Then
strWords(i) = Str2
strWords(i + 1) = Str1
Flag1 = 1
End If
Next
Loop Until Flag1 = 0
For I = 0 To 19
lstWords.Items.Add(strWords(I))
Next
End Sub
End Class

Form1 Enter Some Text Ist Words Click here to sort words

Explanation / Answer

I have changed the code a little bit.

Public Class Form1
Private Sub btnSort_Click(sender As Object, e As EventArgs) Handles btnSort.Click
Dim wrd() As String, PrWrd As String = "", SrtWrdLst As String = ""
TextBox2.Text = Replace(TextBox1.Text, vbCrLf, " ")
wrd = Split(TextBox2.Text.ToLower, " ")
Array.Sort(wrd)
For Each word In wrd
Dim Nwrd As String = "", idx As Int16 = 1
For Each chr As Char In word
Select Case True
Case Char.IsLetter(chr)
NWrd += chr
Case Char.IsDigit(chr)
NWrd = "" : Exit For
Case Char.IsPunctuation(chr)
If idx < word.Length Then NWrd += chr
End Select
idx += 1
Next
If NWrd <> PrWrd Then SrtWrdLst += NWrd & " "
PrWrd = NWrd
Next
TextBox1.Text = SrtWrdLst
End Sub