String Manipulation...

I need to create a function that will take a string from and input box (say a first name), read it one character at a time and redisplay it to the user. This is a school project so I can do this however I chose. My thought was to have a user input his name, the function would count the characters in the string, and redisplay it in a label box. I need help creating this function. I toyed around with the
Len(), and Mid() but I am lost.
cjesgoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bobbit31Commented:
we can't do your homework for you, however, if you post what you have so far, i'm sure we can help you towards a solution
0
cjesgoAuthor Commented:
bobbit31 - after rereading my post I guess that is how I came across...sorry. I just need a some guideness. Here is what I have:

    Dim strFirst As String
    Dim strLast As String
    Dim strFull As String


    'Get the first name for the textbox
    strFirst = txtFname.Text

    'Get the last name from another textbox
    strLast = txtLname.Text

    'Concatenate the first and last name, putting
    'a space character between them.
    strFull = strFirst & " " & strLast
   
    'Display the Full Name
    lblResult.Caption = strFull

Dim szText As String
    Dim nStartingFrom As Integer
    Dim nNumChars As Integer

    '-- Assign szText
    szText = txtFname.Text
   
    '-- Set the starting position
    nStartingFrom = 1

    '-- Set the number of characters
    nNumChars = 1
   
    '-- Print the partial string
    Print Mid$(szText, nStartingFrom, nNumChars)

I imagine I need some sort of counter to keep track of how many characters in the string correct?  Thanks.
0
GERTJANCommented:
Do you mean something like this:

Dim MyValue As String
MyValue = InputBox(Message, Title, Default, 100, 100)

Dim TempChar As String
Dim CountChar As Integer
For I = 1 To Len(MyValue)
    CountChar = CountChar + 1
    TempChar = TempChar + Mid(MyValue, I, 1)
Next I
Label1.Caption = TempChar
Label2.Caption = CountChar
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Thunder27Commented:
Short of doing your project for you, here's an example of how to use a FOR loop to display the string one character at a time.  This will display the results to a text box called Text1.

e.g.

Private Sub ShowResults(sINPUT As String)
   
    For i = 1 To Len(sINPUT)
        Text1.Text = Text1.Text & Mid(sINPUT, i, 1)
    Next i
   
End Sub
0
bobbit31Commented:
> I imagine I need some sort of counter to keep track of how many characters in the string correct?  Thanks

no, that's what the Len function is for

msgbox Len(szText)
0
Thunder27Commented:
Sorry i was typing when you posted that...
To print it out one character at a time, try the following at the end of your code:

'-- Set the number of characters
nNumChars = len(szText)
   
'-- Print the partial string character by character
For i = nStartingFrom to nNumChars
   Print Mid$(szText, i, 1)
Next i
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cjesgoAuthor Commented:
Thunder27 - Thanks! I guess I was closer than I thought.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.