Question:

Visual Basic 6 - first letter on each word upper case?

by  |  earlier

0 LIKES UnLike

i am having trouble please hep me with problem 2

problem 2:

> First letter on each word upper case

> First letter on FIRST word in sentence

You will need:

> To use the ASCII character codes to do this by subtracting 32 from each letter.

> a loop wich moves from the first until the last character, adjusting the case of each charcter as it goes.

> to use radio buttons to select whether it is to be converted to upper or lower case.

To locate each of the characters, one at a time you will need to use:

Mid(Starting position, No. of characters)

IE. If 1 is the first character the position should be 1. then change to 2 and 3 etc. This means you will need a loop to control the progress from one character to the next.

**HINT:

By converting all the text to lower case beforehand, you dont have to worry about checking what cae each letter is.

If you are changing to upper case, you would only need to subtract 32 from he ASCII character code.

>You will need to detect the first letter of a word by detecting the preceding letter as a space.

>to find the start of a sentence, you will need to detect:

Fullstop,

Question mark

Exclimation mark

Each of them followed by a space

You will also need to cosider that "i" is not correct and would be represented as "I".

 Tags:

   Report

1 ANSWERS


  1. something like this:

    Dim str As String

            str = "SFWEUIKJDS"

            str = str.ToLower()

            Dim i As Integer

            Dim next_letter_to_be_capitalized As Boolean = False

            For i = 0 To str.Length - 1

                If str.Substring(i, 1) = " " Or "?" Or "!" Then 'etc

                    next_letter_to_be_capitalized = True

                ElseIf Chr(str.Substring(i, 1)) > 65 & Chr(str.Substring(i, 1)) < 90 Then

                    If next_letter_to_be_capitalized = True Then

                        str = Mid(str, 1, i) & str.Substring(i, 1).ToUpper & Mid(str, i + 2, str.Length - i)

                        next_letter_to_be_capitalized = False

                    End If

                End If

            Next

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.