By: Paul S. Cilwa | Viewed: 5/20/2024 Posted: 1/23/2022 Updated: 1/30/2022 |
Page Views: 1145 | |
Topics: #Organica #VisualBasic #VB.NET #ClassLibrary #OrganicaLib #SuperStrings | |||
Testing String Theory. |
Because the SuperStrings module contains several extensions (mostly to the String class), I envision displaying the results of calling each, in an HTML table. To that end, since building each table row will be a similar job, I'll start by creating a little Private function to build the HTML for each row.
Private Function BuildRow(ExtName As String,
TestString As String,
CallingSeq As String,
TextResult As String) As String
Dim Result As String
Result = "<th>" + ExtName + "</th><td>" + TestString + "</td><td>" + CallingSeq + "</td><td>" + TextResult + "</td></tr>"
Return Result
End Function
With that under our belts, we can code the handler for when the cmd_SuperStrings button is clicked.
Private Async Sub cmd_SuperStrings_Click(sender As Object, e As EventArgs) Handles cmd_SuperStrings.Click
Dim Result As New StringBuilder
Const MyTestString = "Now is the time for all good men to come to the aid of their country."
Const MyQuoteString = """Now is the time for all good men to come to the aid of their country."""
With Result
.Append(StartHtml)
.AppendLine("<table>")
.AppendLine("<tr><th>Extension</th><th>Input Value</th><th>Invocation</th><th>Result</th></tr>")
.AppendLine(BuildRow("Left", MyTestString, "Left(10)", MyTestString.Left(10)))
.AppendLine(BuildRow("Right", MyTestString, "Right(10)", MyTestString.Right(10)))
.AppendLine(BuildRow("Mid", MyTestString, "Mid(10,10)", MyTestString.Mid(10, 10)))
.AppendLine(BuildRow("Enquote", MyTestString, "Enquote", MyTestString.Enquote))
.AppendLine(BuildRow("Dequote", MyQuoteString, "Dequote", MyQuoteString.Dequote))
.AppendLine(BuildRow("LCase", MyTestString, "LCase", MyTestString.LCase))
.AppendLine(BuildRow("UCase", MyTestString, "UCase", MyTestString.UCase))
.AppendLine(BuildRow("SentenceCase", MyTestString, "SentenceCase", MyTestString.SentenceCase))
.AppendLine(BuildRow("TitleCase", MyTestString, "TitleCase", MyTestString.TitleCase))
.AppendLine(BuildRow("ToBool", MyTestString, "ToBool", MyTestString.ToBool.ToString))
.AppendLine("</table>")
.Append(ConcludeHtml)
End With
Await Browser.EnsureCoreWebView2Async()
Browser.CoreWebView2.NavigateToString(Result.ToString)
End Sub
Results
Run the app and click the button. This is the result.