I agree, hence my code is so convoluted no teacher would ever accept it. It is also 4 different ways of solving it with random #### that does nothing.
To be completely honest with you, my code is crazy convoluted (to get you thinking about what is happening). You can do your entire project in 4 lines with only 1 variable.
Think of strings as an array of chars. You access arrays using indexes.
Index 0 = first
Index (length - 1) = last
Index (length / 2 - 1) = middle.
Imagine your string is an array (I show examples of it in my code). Use what I wrote above (substituting length for that actual string length) to achieve what you want.
If I was to write the code in C# it would be something simple ie)
string myString = "myString";
MessageBox.Show("First Letter: " + myString.toString() + " Middle Letter: " + myString[(myString.Length / 2) - 1].ToString() + " Last Letter: " + myString[myString.Length - 1],"Parts of a string");
This is the final code I have:
Public Class frmStringTest
Private Sub btnDisplayData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayData.Click
Dim myString As String = Me.txtPhrase.Text 'declares the phrase enter by the user as a string
Dim stringLen As Integer 'declares as a string
Dim firstletter As String 'declares as a string
Dim lastletter As String 'declares as a string
Dim middleLetter As String 'declares as a string
Dim counter As Integer 'decalres counter as an Integer
For counter = 0 To myString.Length 'The counter starts at O to how many characters/letters are in the word/phrase
stringLen = stringLen + 1 'Goes up by 1
'finding the first letter
firstletter = myString.Substring(0, 1)
Me.lblFirstAnswer.Text = firstletter 'Letter/character for the first letter will display here
'Finding the last letter
lastletter = myString.Substring(stringLen - 2, 1)
Me.lblLastAnswer.Text = lastletter 'Letter/character for the last letter will display here
'Ensures that I have the right letters
firstletter = myString(0)
lastletter = myString(stringLen - 2)
'Finding the middle letter.
For counter = 1 To myString.Length / 2
middleLetter = myString.Substring(counter - 1, 1)
'Step 6, verify it's the middle letter
middleLetter = myString(stringLen / 2 - 1)
Me.lblMiddleAnswer.Text = middleLetter