This is the code that calls the function:
Imports Peasantlish
Public Class main
Dim TranslateLib As Peasantlish.PeasantlishLib
Private Sub Translate()
Label2.Text = "Translator - working"
TextBox1.Text = TranslateLib.TranslateToEng(TextBox2.Text)
End Sub
TextBox2 is the textbox that contains the text to translate. TextBox1 contains the result.
And this is the function itself:
Imports System.Text.RegularExpressions
Public Class PeasantlishLib
Public Function TranslateToEng(ByVal input As String)
Dim output As String = "test string please ignore"
output = input
output = Regex.Replace(output, "full hd", "720p", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "fullhd", "720p", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "xbox live", "free service that I paid for", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "\bxbl\b", "free service that I paid for", RegexOptions.IgnoreCase)
' next are single words after phrases
output = Regex.Replace(output, "\bhd\b", "720p", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "next gen", "already-was-on-pc-3-years-ago gen", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "censored", "bundle of sticks", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "gddr5", "high latency RAM", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "esram", "level 4 cache", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "Controller", "poo-ey excuse for an output device", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "console", "potato", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "cloud", "butt", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "optimization", "ultra low settings", RegexOptions.IgnoreCase)
output = Regex.Replace(output, "optimized", "with ultra low settings", RegexOptions.IgnoreCase)
' and a bunch more of these
Return output
End Function
End Class
It throws the exception at the TextBox1.Text = TranslateLib.TranslateToEng(TextBox1.Text) line. But I don't see anything wrong there. It worked fine before I migrated the bunch of Regex.Replace's to a .dll for tidiness purposes. Before the output variable was TextBox1.Text