document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. Public Class Form1
  2.     Private Sub Button1_Click(sender As Button, e As EventArgs) Handles Button1.Click
  3.         Dim date1, date2 As DateTime, dif As TimeSpan
  4.         RichTextBox1.ReadOnly = True : RichTextBox2.ReadOnly = True
  5.         sender.Enabled = False
  6.         RichTextBox3.Text = String.Empty
  7.         sender.Text = "Calculating"
  8.         Label4.Text = "Inspecting First Number..." : MakeNumber(RichTextBox1.Text, RichTextBox1)
  9.         Label4.Text = "Inspecting Second Number..." : MakeNumber(RichTextBox2.Text, RichTextBox2)
  10.         date1 = Now
  11.         If RichTextBox1.Text.Length >= RichTextBox2.Text.Length Then _
  12.             HumanAddition(RichTextBox1.Text.ToCharArray, RichTextBox2.Text.ToCharArray) Else _
  13.             HumanAddition(RichTextBox2.Text.ToCharArray, RichTextBox1.Text.ToCharArray)
  14.         date2 = Now
  15.         dif = date2 - date1
  16.         Label3.Text = "Answer: " & RichTextBox3.TextLength & " / 2147483647"
  17.         Label4.Text = "Calculation finished in: " & CInt(dif.TotalMilliseconds) & "ms"
  18.         sender.Text = "Calculate"
  19.         RichTextBox1.ReadOnly = False : RichTextBox2.ReadOnly = False
  20.         sender.Enabled = True
  21.     End Sub
  22.     Private Sub TextBox_TextChanged(sender As RichTextBox, e As EventArgs) Handles RichTextBox1.TextChanged, RichTextBox2.TextChanged
  23.         If sender.Name = "RichTextBox1" Then _
  24.             Nums1Count.Text = "1st number: " & RichTextBox1.TextLength & " / 2147483646" Else _
  25.             Nums2Count.Text = "2nd number: " & RichTextBox2.TextLength & " / 2147483646"
  26.     End Sub
  27.     Private Sub MakeNumber(ByVal input As String, ByRef output As RichTextBox)
  28.         Dim l As Integer = 0
  29.         While l < input.Length
  30.             Select Case input(l)
  31.                 Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" : l += 1 : Application.DoEvents()
  32.                 Case Else : input = input.Replace(input(l), String.Empty) : Application.DoEvents()
  33.             End Select
  34.         End While
  35.         output.Text = input
  36.     End Sub
  37.     Private Sub HumanAddition(ByVal nums1() As Char, ByVal nums2() As Char)
  38.         Dim carry As Integer = 0
  39.         Dim crntcalc As Integer = 0
  40.         Dim result() As Char = " " & nums1
  41.         Dim nums1marker As Integer = nums1.Length
  42.         Dim numsdif As Integer = nums1marker - (nums1marker - nums2.Length)
  43.         Dim num2index = numsdif - (nums1marker - nums1marker)
  44.         For i = nums1marker - 1 To 0 Step -1
  45.             num2index -= 1
  46.             If num2index >= 0 Then crntcalc = result(i + 1).ToString * 1 + nums2(num2index).ToString Else crntcalc = nums1(i).ToString
  47.             If carry > 0 Then
  48.                 crntcalc += carry
  49.                 If i > 0 Then carry = 0
  50.             End If
  51.             If crntcalc > 9 Then
  52.                 carry = crntcalc.ToString.First.ToString
  53.                 result(i + 1) = crntcalc.ToString.Last
  54.             Else : result(i + 1) = crntcalc.ToString
  55.             End If
  56.             If i = 0 And crntcalc > 9 Then
  57.                 result(0) = carry.ToString
  58.                 carry = 0
  59.             ElseIf num2index < 0 And carry = 0 Then : Exit For
  60.             End If
  61.             ProgressBarPro.Width = ((nums1marker - i) * Panel1.Width) / nums1marker
  62.             Label4.Text = "Calculating: %" & CInt(((nums1marker - i) * 100) / nums1marker)
  63.             Application.DoEvents()
  64.         Next
  65.         ProgressBarPro.Width = Panel1.Width
  66.         Label4.Text = "Calculating: %100"
  67.         RichTextBox3.Text = New String(result).TrimStart(New Char() {" ", "0"})
  68.         Label4.Text = 100
  69.     End Sub
  70. End Class
');