Click here to Skip to main content
15,860,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to the initials form an input box.

for example John Smith Brown I want JSB

What I have tried:

VB
Dim name As String
name = InputBox("Enter your name", "name")
Dim NameArr() As String
Dim i, initial As String
Dim count As Integer
i = ""
name = ""
nameArr = name.Split(" ")
For count = 0 To NameArr.Length - 1

    i = NameArr.Substring(0, 1)
Next
Posted
Updated 20-Jul-16 10:54am
v3

1 solution

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

VB
Dim name As String
name = InputBox("Enter your name", "name")
Dim NameArr() As String
Dim i, initial As String
Dim count As Integer
i = ""
name = "" ' error: this line clear the contain of name, remove
nameArr = name.Split(" ")
For count = 0 To NameArr.Length - 1
     i = NameArr.Substring(0, 1) ' error, replace with
     i = i + NameArr.Substring(0, 1)
Next
 
Share this answer
 

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