VB6 Left & Right functions allowed the usage of out-of-bounds indexes, automatically replacing them with the actual lower/upper bound as required. Converting these methods directly to “Substring” invocations could cause the firing of out-of-bounds exceptions which were not triggered in VB6.
If this optional feature is enabled the Visual Basic Upgrade Companion will add Math.Max and Math.Min invocations to the resulting code in order to avoid out-of-bounds exceptions. This is a brief usage example:
Private Sub method1() Dim String1 As String String1 = "this is the string content" MsgBox Right(String1, 247) MsgBox Left(String1, 714) End Sub
Private Sub method1() Dim String1 As String = "this is the string content" MessageBox.Show(String1.Substring(String1.Length - Math.Min(String1.Length, 247)), Application.ProductName) MessageBox.Show(String1.Substring(0, Math.Min(String1.Length, 714)), Application.ProductName) End Sub
private void method1(){ string String1 = "this is the string content"; MessageBox.Show(String1.Substring(String1.Length - Math.Min(String1.Length, 247)), Application.ProductName); MessageBox.Show(String1.Substring(0, Math.Min(String1.Length, 714)), Application.ProductName); }
8834 N Capital of Texas Hwy, Ste 302
Austin, TX 78759
Call us: +1 (425) 609-8458
info@wearegap.com