I have a Problem here in my casing function. I used replace to change the all conjunction into a lower but still i have an error>
Private Function UpCsing(ByVal sValue As String) As String
Dim toConvert As String() = sValue.Split(" ")
Dim lst As New List(Of String)
For i As Integer = 0 To toConvert.Length - 1
Dim converted As String = ""
If toConvert(i).Contains("^") Then
converted = toConvert(i).ToUpper.Replace("^", "")
Else
converted = StrConv(toConvert(i), VbStrConv.ProperCase).Replace("^", "")
End If
lst.Add(converted)
Next
Dim ret As String = ""
For i As Integer = 0 To lst.Count - 1
If i = 0 Then
ret = lst(0)
Else
ret += " " + lst(i)
End If
Next
Return ret.Replace(" For ", " for ").Replace(" In ", " in ").Replace(" Of ", " of ").Replace(" And ", " and ").Replace(" And/Or ", " and/or ").Replace(" By ", " by ") _
.Replace(" By ", " by").Replace(" 2Nd ", " 2nd ").Replace(" 3Rd ", " 3rd ").Replace(" At ", " at ").Replace("And/Or ", "and/or ").Replace("1St", "1st").Replace("2Nd", "2nd").Replace("3Rd", "3rd") _
.Replace("At ", "at ").Replace(" At", " at").Replace(" Of", " of").Replace(" & ", " and ").Replace("Poc", "POC").Replace(" As ", " as ") _
.Replace("C/O", "c/o").Replace("$ ", "$").Replace(" And/Or ", " and/or ")
End Function
error sample: 'For' should be 'for' but the word 'Forward' must be 'Forward' by my output change it into 'forward'
Example 'For the main event and for us to forward' the output should be 'For the Main Event and for us to Forward'
I tried with this code:
And I get the correct result:
Edit:
Your code outputs Forward with a capital F, which exactly what you expect.
Edit 2:
The reason is because all words that are not prefixed/appended with ^ are converted to ProperCase with this line of code:
Tip: there is no need to replace ^ with "" because words converted to ProperCase are not refixed/appended with ^.