Hi! I am trying to do this project for my Comp Prog class. The Project assignment is "Create an application that prompts the user to enter his/her and last name in a single text box. The program returns the user initials in uppercase".
This is what i have. I am using listboxes for now instead to display the initial.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Name, F, Last As String
Dim Cnt As Integer = 0
Name = TextBox1.Text
Last = Name.Chars(cnt)
For Cnt = 0 To (Name.Length) - 1
Last = Name.Chars(Cnt)
If Last = " " Then
Cnt = cnt + 1
End If
Next
F = Name.Chars(0)
listbox1.items.add(F.ToString.ToUpper & Last.ToString.ToUpper)
End Sub
End Class
Alright so basically i created variables Names, Last, and F. And Cnt for a counter that equals 0. Set Name to textbox1.text, which i will enter the name. And Last is equal to Name.Chars(Cnt) (So last is queal to textbox1 (name) and character cnt, which is 0. Then i created a for next loop, to which Cnt = 0 to the length of the name. - 1 because ... EX) TOM JONES, is 0,1,2,3,4,5,6,7,8. The Length is of TOM JONES is 9(w/o the 0), so you have to subtract - 1. OK, so i set up a If, then. If Last = " " (BLANK) then the counter = counter + 1... So F is then equal to Char 0, which is the first letter of the name, and add everything to a listbox..
So if i put in a name, Tom Jones for example, it shows TS, The last and first letter, EX) Bob Jones, will display BS.. When it is supposed to be BJ.
Can anyone help me? I been trying to this for the past couple of hours and have no idea what im doing wrong.
Can someone please Help